PAT 乙级 1001 题解 (Basic Level) Practice

版权声明:本文为博主原创文章,转载请说明出处。 https://blog.csdn.net/qq278672818/article/details/81127061
#include<cstdio>

int main()
{
    int i = 0, n;
    scanf("%d", &n);
    while(n != 1)
    {
        i++;
        if(n%2 == 0)
            n = n/2;
        else
            n = (3*n+1)/2;
    }
    printf("%d",i);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq278672818/article/details/81127061
今日推荐