模拟一下
2024-08-17 13:34:47
发布于:云南
3阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
if(n != 1){
int now = n;
while(now != 1){
if(now % 2 != 0){
cout << now << "*3+1=" << now * 3 + 1 << endl;
now = now * 3 + 1;
}else{
cout << now << "/2=" << now / 2 << endl;
now /= 2;
}
}
}
cout << "End";
return 0;
}
这里空空如也
有帮助,赞一个