求助 #75分 感谢

B2077 角谷猜想

ZM_123_ @ 2023-04-26 22:11:37

还有为什么不给c一开始赋值的话就只输出End? 感谢

#include <stdio.h>
int main()
{
    long long a,c=0;
    scanf("%lld",&a);
    while(c!=1){
        if(a%2!=0){
            c=a*3+1;
            printf("%lld*3+1=%lld\n",a,c);
            a=c;
        }
        else{
        c=a/2;
        printf("%lld/2=%lld\n",a,c);
        a=c;    
        }
    }
    printf("End");
    return 0;
}

by ZM_123_ @ 2023-04-26 22:16:13

为什么要用 long long ,不用int 是后面会爆吗


by lraM416 @ 2023-04-26 22:24:42

@ZM123 一开始不赋值不满足循环条件,当然输出end


by ZM_123_ @ 2023-05-05 20:50:56

@Algae 感谢,过了


by ZM_123_ @ 2023-05-05 20:51:31

@ZM123 循环条件错误


|