ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1226. esreveR redrO

C++ AC source here (+)
Posted by Beksinski 2 Aug 2003 20:17
Why you don't use C++ & STL? It more effectively then awful
pascal !!!


#include <iostream.h>
#include <ctype.h>

#include <stack>
using namespace std;

stack<char> st;

void flush_stack(){
    int n = st.size(), i;
    if (n>0) {
        for(i=0; i<n; ++i){
            cout<<st.top();
            st.pop();
        }
    }
}

int main () {
    char pch[1];

    while (1) {
        cin.read(pch, 1);
        if (cin.eof()) break;
        if (isalpha(*pch)) {
            st.push(*pch);
        } else {
            flush_stack();
            cout.write(pch, 1);
        }
    }
    flush_stack();

    return 0;
}