4 条题解

  • 1
    @ 2022-8-22 9:27:27
    using namespace std;
    int n;
    int a;
    int main(){
    	cin>>n;
    	while(n!=0){
    		if(n%2==1){
    			a=n;
    			n=n*3+1;
    			cout<<a<<"*"<<3<<"+"<<1<<"="<<n<<endl;
    		}else{
    			a=n;
    			n/=2;
    			cout<<a<<"/"<<2<<"="<<n<<endl;
    		}
    		if(n==1){
    			cout<<"End"<<endl;
    			return 0;
    		}
    	}
    	return 0;
    }
    
    • 0
      @ 2023-3-3 21:04:44

      #include <bits/stdc++.h> using namespace std;

      int x; int main() { cin>>x; while(x!=1) { if(x%2==1) { cout<<x<<"3+1="<<x3+1<<endl; x=x*3+1; } else { cout<<x<<"/2="<<x/2<<endl; x=x/2; } } cout<<"End"; return 0; }

      • 0
        @ 2022-11-11 16:12:13

        #include <bits/stdc++.h> using namespace std; int main( ) { int x,s; cin>>x; while(x>1) { if(x%2!=0) { printf("%d3+1=%d\n",x,x3+1); x=x*3+1; } else { printf("%d/2=%d\n",x,x/2); x=x/2; }

        }
        if(x==1)
        {
        	cout<<"End";
        }
        

        return 0; }

        • 0
          @ 2022-8-2 14:28:35

          #include <iostream> using namespace std; int print(int i){ if(i%2==0){ cout<<i<<"/2="<<i/2<<endl; return i/2; }

          else{
              cout<<i<<"*3+1="<<i*3+1<<endl;
              return i*3+1;
          }
          

          } int main() { int a; cin>>a; if(a!=1) while(a!=1) a=print(a); cout<<"End"; return 0; }

          • 1

          信息

          ID
          79
          时间
          1000ms
          内存
          256MiB
          难度
          1
          标签
          递交数
          48
          已通过
          34
          上传者