#include<stdio.h>
#include<math.h>
int main()
{
int n;
n<=pow(,);
int count=;
scanf("%d",&n);
while(n!=)
{
count++;
if(n%==)
n=n/;
else
n=n*+;
}
printf("%d\n",count);
return ;
}

HINT

使用 while 循环使用 while 语句在条件成立时重复某动作,类似于 if 语句,只要条件为 true 就重复动作。 while 循环计算一个表达式的值,如果表达式为 true,则会执行循环体中的代码。如果条件计算结果为 true,在循环返回以再次计算条件前执行一条语句或一系列语句。条件计算结果为 false 后,则跳过语句或一系列语句并结束循环。在不确定要将一个代码块循环多少次时,使用 while 循环可能会非常有用。 例如,下面的代码将数字显示到"输出"面板中: var i:Number = 0; while (i < 5) { trace(i); i++; } 您会看到以下数字显示到"输出"面板中: 0 1 2 3 4 使用 while 循环而非 for 循环的一个缺点是,在 while 循环中更有可能编写出无限循环。如果遗漏递增计数器变量的表达式,则 for 循环示例代码将无法编译;而 while 循环示例代码将能够编译。若没有递增 i 的表达式,循环将成为无限循环。

Problem E: 零起点学算法34——3n+1问题的更多相关文章

  1. Problem J: 零起点学算法34——3n+1问题

    #include<stdio.h> int main() { ; int n; scanf("%d",&n); ) { ==) n=n*+; else n/=; ...

  2. 1129: 零起点学算法36——3n+1问题

    1129: 零起点学算法36--3n+1问题 Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 4541 ...

  3. 武汉科技大学ACM:1004: 零起点学算法36——3n+1问题

    Problem Description 任给一个正整数n,如果n为偶数,就将它变为n/2,如果为奇数,则将它乘3加1(即3n+1).不断重复这样的运算,经过有限步后,一定可以得到1 . Input 输 ...

  4. 武汉科技大学ACM :1001: 零起点学算法34——继续求多项式

    Problem Description 输入1个正整数n, 计算1+(1+2)+(1+2+3)+...+(1+2+3+...+n) Input 输入正整数n(多组数据) Output 输出1+(1+2 ...

  5. Problem H: 零起点学算法109——单数变复数

    #include <stdio.h> #include<string.h> int main(void) { int n; ]; scanf("%d",&a ...

  6. Problem G: 零起点学算法106——首字母变大写

    #include<stdio.h> #include<string.h> int main(void) { ]; int i,k; while(gets(a)!=NULL) { ...

  7. Problem D: 零起点学算法95——弓型矩阵

    #include<stdio.h> #include<string.h> int main() { ][]; while(scanf("%d%d",& ...

  8. Problem F: 零起点学算法42——多组测试数据输出II

    #include<stdio.h> int main() { ; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { ...

  9. Problem K: 零起点学算法107——统计元音

    #include<stdio.h> int main() { int n; ]; while(scanf("%d%*c",&n)!=EOF) { while(n ...

随机推荐

  1. [转]python os模块 常用命令

    python编程时,经常和文件.目录打交道,这是就离不了os模块.os模块包含普遍的操作系统功能,与具体的平台无关.以下列举常用的命令 1. os.name()——判断现在正在实用的平台,Window ...

  2. python基础===【爬虫】爬虫糗事百科首页图片代码

    import requests import re import urllib.request def getHtml(url): page = requests.get(url) html = pa ...

  3. linux内核启动分析(3)

    主要分析do_basic_setup函数里面的do_initcalls()函数,这个函数用来调用所有编译内核的驱动模块中的初始化函数. static void __init do_initcalls( ...

  4. Xcode7 iOS9.0 的真机调试

    Xcode7的真机调试: 1.Xcode偏好 -> 账号 -> 增加 Apple ID ->显示 free 2.Target 运行 iOS 版本号 3.修正 Team 项   选择 ...

  5. Makefile系列之二 : 命令

    一.显示命令 echo “@”字符可以控制命令是否在屏幕上显示,如 @echo 正在编译XXX模块......  输出: 正在编译XXX模块...... 如果没有“@"则输出 : echo ...

  6. LeetCode解题报告—— Regular Expression Matching

    Given an input string (s) and a pattern (p), implement regular expression matching with support for  ...

  7. mysql-表完整性约束

    阅读目录 一 介绍 二 not null与default 三 unique 四 primary key 五 auto_increment 六 foreign key 七 总结     一 介绍 回到顶 ...

  8. AC日记——[POI2014]KUR-Couriers 洛谷 P3567

    [POI2014]KUR-Couriers 思路: 卡空间,sb题: 代码: #include <bits/stdc++.h> using namespace std; #define m ...

  9. .net core 2.0学习记录(三):内置IOC与DI的使用

    本篇的话介绍下IOC和ID的含义以及如何使用.Net Core中的DI. 一.我是这么理解IOC和DI的: IOC:没有用IOC之前是直接new实例来赋值,使用IOC之后是通过在运行的时候根据配置来实 ...

  10. catalina.out日志切割

    安装cronlog rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum ins ...