北邮OJ 136 反转单词

北邮OJ 反转单词

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;

int main(){
	string ss;
	stack <string>s;
	while(cin>>ss){
		s.push(ss);
		if(cin.get()=='\n'){
			while(1){
				ss=s.top();
				s.pop();
				cout<<ss;
				if(s.empty())
					break;
				else
					cout<<" ";
			}
			cout<<endl;
		}
	}
}

猜你喜欢

转载自blog.csdn.net/bingkuoluo_/article/details/88808599
136