提交时间:2024-01-28 17:41:51
运行 ID: 38866
#include<iostream> using namespace std; int main() { int n; cin>>n; while(n!=1){ if(n%2==0){ int a=n/2; cout<<n<<"/2="<<a<<endl; n=n/2; } else if(n%2==1){ int b=n*3+1; cout<<n<<"*3+1="<<b<<endl; n=n*3+1; } } cout<<"End"<<endl; return 0; }