我用的栈,tmd前三个测试点RE,后两个WA,dalao帮忙看看
#include <bits/stdc++.h>
using namespace std;
stack<int> st;
int n, tmp;
int main(){
cin >> n;
tmp = n;
while(n != 1){
if(n % 2 == 0){
n /= 2;
st.push(n);
}
else{
n *= 3;
n++;
st.push(n);
}
}
for(int i = 0;i < tmp;i++){
cout << st.top();
st.pop();
}
return 0;
}
记录详情