题解
2025-11-01 15:14:07
发布于:广东
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int f(int x){
if (x == 1){
cout << "1";
return 0;
}
printf("%d->", x);
if (x % 2 == 0){
return f(x / 2);
} else {
return f(3 * x + 1);
}
}
int main(){
int n;
cin >> n;
f(n);
}
这里空空如也







有帮助,赞一个