用栈写的,为什么全WA了?
查看原帖
用栈写的,为什么全WA了?
1292449
nanlnan楼主2024/8/21 09:20
#include<bits/stdc++.h>
using namespace std;

int main(){
stack<char>s;
while(true){
char ch=getchar();
if(ch==' '||ch=='\n'||ch==EOF){
while(!s.empty()){cout<<s.top(); s.pop();}
if(ch=='\n'||ch==EOF)break;
cout<<endl;
}
else s.push(ch);
}
return 0;
}
2024/8/21 09:20
加载中...