代码已经AC,写的有点笨拙,大佬们多指点哈
#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;
}
网友评论