#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. bootstrap-select属性

    # 参考:https://blog.csdn.net/zxl_langya/article/details/79247307 # bootstrap-select属性: <select mult ...

  2. c#上传文件时,当选择的文件为0kb,会验证不通过

    FileUpload1.HasFile 当FileUpload1控件选择的文件为0KB时,FileUpload1.HasFile返回false

  3. 集合类---Map

    Map常用的子类: 一.HashMap详解  1.特点 1)线程不安全.如果想要得到线程安全的HashMap,可以使用Collections的静态方法:Map map = Collections.sy ...

  4. CF625D Finals in arithmetic-构造,贪心,细节

    题目链接:http://codeforces.com/contest/625/problem/D 题意: 给你一个数字字符串s,长度1e6,算是一个大数吧,让你找到一个x,使得,x加上  逆转(x)= ...

  5. openstack前期准备

    . 两台虚拟机,安装Centos7系统 两个网卡 -- 一个NAT模式,一个仅主机模式 两个硬盘 -- 一个20GB,一个50GB 内存 -- 主 .6GB(根据自己的配置,大于2G即可) 从 1.6 ...

  6. ES6 一种新的数据结构--Map跟Objct的区别

    var map1=new Map(); var keys={key:'val'}; map1.set(keys,'content'); ==> {Object {key: "val&q ...

  7. Django在根据models生成数据库表时报错

    报错信息: E:\Python\s6day103>python manage.py makemigrations Traceback (most recent call last): File ...

  8. hadoop3.1集成yarn ha

    1.角色分配

  9. Google的C++开源代码项

    转:http://blog.csdn.net/wenrenhua08/article/details/40040903 v8  -  V8 JavaScript EngineV8 是 Google 的 ...

  10. [图解算法]线性时间选择Linear Select——<递归与分治策略>

    #include <ctime> #include <iostream> using namespace std; template <class Type> vo ...