三发
2026-09-22 20:40:50
发布于:浙江
5阅读
0回复
0点赞
我是三发!!前面两个,这道题官方给的知识点明明是栈,为什么不用栈做
题解(用栈做)如下
#include<bits/stdc++.h>
using namespace std;
int main(){
stack<int>st;
for(int i=1;;i++){
int x;
cin>>x;
if(x==0){
break;
}
st.push(x);
}
while(!st.empty()){
cout<<st.top()<<" ";
st.pop();
}
return 0;
}
这里空空如也

有帮助,赞一个