#include<iostream>
#include<cstdio>
using namespace std;
int main() {
int tem;
int n, num = 0;
scanf("%d",&n);
while (n != 1) {
if (n % 2 == 0)
n = n / 2;
else
n =( 3 * n + 1)/2;
num++;
}
printf("%d", num);
cin >> tem;
return 0;
}
总结:
1.输入要加&
2.条件判断while(n!=1)