View Code of Problem 114

#include<bits/stdc++.h> 
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		stack<char>sta;
		for(int cur=0;cur<s.length();cur++){
			if(isalpha(s[cur])){
				sta.push(s[cur]);
			}else if(!isalpha(s[cur])){
				while(!sta.empty()){
					cout<<sta.top();
					sta.pop();
				}
				cout<<s[cur];
			}
		}
		while(!sta.empty()){
					cout<<sta.top();
					sta.pop();
				}
	cout<<endl;
	}
}
 
 

Double click to view unformatted code.


Back to problem 114