hailestone
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n, length = 0;
scanf_s("%d", &n);//输入某个n值
while (1 < n)
{
n=n % 2 ? (n / 2) : (3 * n + 1);//判断某个数是否为奇偶,偶数执行n/2,奇数执行3n-1;
cout << n << endl;//输出所有的n值
length++;
}
cout << "length="<<length<<endl;//输出循环的n值个数
}
最后
以上就是傻傻果汁最近收集整理的关于【无标题】的全部内容,更多相关【无标题】内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复