c语言编程练习题:7-122 3n 1
作者:yunjinqi   类别:    日期:2023-05-31 16:36:50    阅读:126 次   消耗积分:0 分    

image.png

#include <stdio.h>
int main(){
    int n;
    int count=0;
    if (scanf("%d",&n)!=EOF){
        while (n!=1){
            if (n%2==0){n=n/2;}
            else{n=3*n+1;}
            count++;
        }
        printf("%d",count);
    }
    else{
        printf("input wrong");
    }
    return 0;
}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/247
上一篇:c语言编程练习题:7-121 作品评分
下一篇:c语言编程练习题:7-123 空心字母金字塔