入门题。注意输入值为1时应当不需要走考拉兹猜想而直接输出0。

#include <bits/stdc++.h>
#define _CRT_SECURE_NO_DEPRECATE

int main() {
    int n, result;
    while (std::cin >> n) {
        result = 0;
        if (n != 1) {
            do {
                if (n % 2) {
                    n = (3 * n + 1) / 2;
                } else {
                    n /= 2;
                }
                result++;
            } while (n != 1);
        }
        std::cout << result << std::endl;
    }
    return 0;
}