#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代码这样写更优雅(转)

    1.变量交换 大部分编程语言中交换两个变量的值时,不得不引入一个临时变量: >>> a = 1>>> b = 2>>> tmp = a>&g ...

  2. 【nginx】nginx的安装及测试

    nginx中文文档:http://www.nginx.cn/doc/index.html 1.到官网下载nginx的压缩包: https://nginx.org/   2.解压到相应的目录,比如我是e ...

  3. Part2-HttpClient官方教程-Chapter6-HTTP缓存(HTTP Caching)

    原文链接 6.1. 一般概念 HttpClient Cache提供了一个与HTTP / 1.1兼容的缓存层与HttpClient(浏览器缓存的Java等价物.)一起使用.该实现遵循责任链设计模式,其中 ...

  4. Reactor与Proactor区别

    如网络编程中accept之后等待数据到达,并且读取数据为例: Reactor: 基于同步IO 1. 线程等待读取socket数据,将socketfd添加到事件分派器中,如添加到epoll: 2. 事件 ...

  5. [device tree] interrupt mapping example

    This is for Devicetree Specification Release 0.1 Interrupt Mapping Example p19 在講解前,先帶進一些 PCI 的基礎觀念 ...

  6. mips64高精度时钟引起ktime_get时间不准,导致饿狗故障原因分析【转】

    转自:http://blog.csdn.net/chenyu105/article/details/7720162 重点关注关中断的情况.临时做了一个版本,在CPU 0上监控所有非0 CPU的时钟中断 ...

  7. 使用IDA PRO+OllyDbg+PEview 追踪windows API 动态链接库函数的调用过程

    使用IDA PRO+OllyDbg+PEview 追踪windows API 动态链接库函数的调用过程 http://blog.csdn.net/liujiayu2/article/details/5 ...

  8. sicily 1009. Mersenne Composite N

    Description One of the world-wide cooperative computing tasks is the "Grand Internet Mersenne P ...

  9. C中级 MariaDB Connector/C API 编程教程

    引言 - 环境搭建 首先开始环境搭建. 主要在Window 10 + Visual Studio 2015 上构建使用 mariadb connector/c api 进行数据操作开发. 为什么选择在 ...

  10. DevExpress.XtraTreeList 小结

    搞了半天才绑定好,没有弄清楚父子之间的关系 <dx:ASPxTreeList ID="ASPxTreeList1" runat="server" Auto ...