#include<iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
if (n == 0) {
break;
}
int count = 0;
while (n != 1) {
if (n % 2) {
n = (3 * n + 1) / 2;
} else {
n = n / 2;
}
count++;
}
printf("%d\n", count);
}
}
嵌套了多层while,只要不搞错,此题不难

京公网安备 11010502036488号