代碼已經(jīng)AC厦滤,寫的有點(diǎn)笨拙溯祸,大佬們多指點(diǎn)哈
#include<stdio.h>
int main()
{
int n,flag = 0;
scanf("%d",&n);
while (n != 1)
{
if(n %2 == 0)
n /= 2;
else
n = (3*n+1)/2;
flag++;
}
printf("%d",flag);
return 0;
}