#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. javascript中数据属性与访问器属性

    1.数据属性 Configurable:true|false,表示能否通过delete将属性删除,默认为true.当把属性的Configurable设置为false后,该属性不能通过delete删除, ...

  2. hdfs基本思想

    1.hdfs的优缺点 (1)不适合大量小文件存储: (2)不适合并发写入,不支持文件随机修改:(只能append追加) (3)不支持随机读等低延时的访问方式 2.基本思想 主从结构 主节点, name ...

  3. [Leetcode Week15]Populating Next Right Pointers in Each Node II

    Populating Next Right Pointers in Each Node II 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/popul ...

  4. sk_buff结构

    sk_buff结构用来描述已接收或者待发送的数据报文信息:skb在不同网络协议层之间传递,可被用于不同网络协议,如二层的mac或其他链路层协议,三层的ip,四层的tcp或者udp协议,其中某些成员变量 ...

  5. kernel defconfig

    Some defconfig files are placed on below path. Only one *_defconfig can be selected. android/kernel/ ...

  6. 安全测试===sqlmap

    本文转自:https://www.secpulse.com/archives/4213.html   鉴于很多新手对sqlmap的用法不是很熟悉 很多常用sqlmap的也不一定完全会用sqlmap 特 ...

  7. C#数据没初始化,使用会报错,可以初始化null

    protected void Page_Load(object sender, EventArgs e) { string[] A; if (B== 0) { A = new string[] {1, ...

  8. jstorm相关

    https://www.cnblogs.com/antispam/p/4182210.html

  9. 【bzoj4567】SCOI2016背单词

    题号莫名喜感. 倒序建Trie,dfs这棵Trie,贪心一下,每次按照size排序计算贡献就好. #include<bits/stdc++.h> #define N 100010 #def ...

  10. C后端设计开发 - 第7章-真气-遗失的网络IO

    正文 第7章-真气-遗失的网络IO 后记 如果有错误, 欢迎指正. 有好的补充, 和疑问欢迎交流, 一块提高. 在此谢谢大家了. ボクらの冒険 : http://music.163.com/#/m/s ...