who can answer me?

B2077 角谷猜想

doublecrosser @ 2022-02-15 20:42:09

第四个点错了
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n>0){
        if(n%2==0){
        cout<<n<<"/2="<<n/2;
        cout<<endl;
        n=n/2;
        }
        else{
        cout<<n<<"*3+1="<<n*3+1;
        cout<<endl;
        n=n*3+1;
        }
        if(n==1) break;

    }
    cout<<"End";
    return 0;
}

by 8atemak1r @ 2022-02-15 20:46:55

@doublecrosser

如果输入为 1,直接输出 End

请认真读题。


by doublecrosser @ 2022-02-17 21:47:05

好滴好滴


by ZHR20100222 @ 2022-08-04 16:23:12

@doublecrosser

可以这样while:

while(n!=1){

}

|