#include <iostream>
#include <string.h>
#include <stdio.h>
#include <string>
#include <stack>
using namespace std;
char str[1005];
stack <string> st;
int main()
{
char str[105];
gets(str);
int Begin=0,End=0;
for(int i=0;i<strlen(str);i++)
{
if(str[i]==' ')
{
End=i;
string s;
int t=0;
for(int j=Begin;j<End;j++)
{
s.push_back(str[j]);
}
st.push(s);
Begin=End+1;
}
}
string s;
for(int i=Begin;i<strlen(str);i++)
{
s.push_back(str[i]);
}
st.push(s);
int flag=1;
while(!st.empty())
{
if(flag){
flag=0;
cout<<st.top();
}
else{
cout <<' '<<st.top();
}
st.pop();
}
cout << endl;
return 0;
}
单词倒排
最新推荐文章于 2023-11-26 18:34:08 发布