解题思路:
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int n,tem;
scanf("%d",&n);
tem=n;
while(tem!=1)
{
if(n%2==0)
{
tem=n/2;
printf("%d/2=%d\n",n,tem);
n=n/2;
}
else
{
tem=n*3+1;
printf("%d*3+1=%d\n",n,tem);
n=n*3+1;
}
}
return 0;
}
0.0分
4 人评分
简单的a+b (C语言代码)浏览:643 |
简单的a+b (C语言代码)浏览:759 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:500 |
C语言训练-大、小写问题 (C语言代码)浏览:2349 |
C语言训练-字符串正反连接 (C语言代码)浏览:618 |
简单的a+b (C语言代码)浏览:547 |
母牛的故事 (C语言代码)浏览:915 |
C语言训练-阶乘和数* (C语言代码)-------- 呆板写法浏览:1345 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:676 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1326 |