提交时间:2026-01-04 15:33:07
运行 ID: 80832
#include <iostream> using namespace std; int main() { int n; cin >> n; while (n != 1) { if (n % 2 == 1) { // 奇数:乘3加1 cout << n << "*3+1=" << n * 3 + 1 << endl; n = n * 3 + 1; } else { // 偶数:除以2 cout << n << "/2=" << n / 2 << endl; n = n / 2; } } cout << "End" << endl; return 0; }