View Code of Problem 114

#include<stdio.h>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;

//无法通过
int main()
{
	string str;
	while (getline(cin, str)) {
		stack<char> pp;
		for (int i = 0; i < str.size(); i++) {
			if ((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z')) {
				pp.push(str[i]);
			}
			else {
				while (!pp.empty()) {
					cout << pp.top();
					pp.pop();
				}
				cout << str[i];
			}
		}

		while (pp.size() != 0) {
			cout << pp.top();
			pp.pop();
		}
		
		cout << endl;
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114