提交时间:2024-02-01 21:34:36

运行 ID: 39526

#include<iostream> using namespace std; int main() { int n; cin>>n; if(n==1) cout<<"End"; else while(n!=1){ if(n%2==1){ cout<<n<<"*3+1="<<n*3+1<<endl; n=n*3+1; } if(n%2==0){ cout<<n<<"/2="<<n/2<<endl; n=n/2; } } cout<<"End"; return 0; }