竞赛
考级
YuQing1919
MuktorFM
#include<bits/stdc++.h> using namespace std; int main(){ int n,j; cin>>n; for(int i=1;1<n;i++){ if(n%2!=0){ j=n*3+1; cout<<n<<"*3+1="<<j<<endl; n=j; }if(n%2==0){ j=n/2; cout<<n<<"/2="<<j<<endl; n=j; } } cout<<"End"; return 0; }
188****7602
黑客_天之神_ZDZL_zsy
枫岚
#include<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a; while(a!=1){ if(a%2==0){ b=a; a/=2; cout<<b<<'/'<<2<<'='<<a<<endl; }else{ b=a; a=a3+1; cout<<b<<''<<3<<'+'<<1<<'='<<a<<endl; } } cout<<"End"; return 0; }
???
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; while(n!=1){ if(n%2==0){ cout<<n<<"/2="<<n/2<<endl; n/=2; } else{ cout<<n<<"3+1="<<n3+1<<endl; n=n*3+1; } } cout<<"End"; return 0; }
13nc
应该不难吧?
135****0128
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; while(true){ if(n % 2 == 1){ cout << n << "*3+1="; n = n * 3 + 1; cout << n << endl; }else{ cout << n << "/2="; n /= 2; cout << n << endl; } if(n == 1){ cout << "End"; break; } } return 0; }
(⊙﹏⊙)
#include <iostream> using namespace std; int main(){ int a; cin>>a; while( a!=1){ if(a%21){ cout<<a<<"3+1="<<a3+1<<endl; a=a*3+1; }else{ cout<<a<<"/2="<<a/2<<endl; a=a/2; } } if(a1){ cout<<"End"; } return 0; }
金杰錱
共30条