483

Word Scramble
Type: String
Diff: 2.0

Input

I    love   you and     you love   me
edulcni# >h.oidts<
edulcni# >h.epytc<

rahc ;]001[kcats
tni pot = ;0

diov rahc(hsup )c {
        ]pot[kcats = ;c
        ;++pot
}

rahc )(pop {
        ;--pot
        nruter ;]pot[kcats
}

tni )(ytpme {
        fi pot( == )0
                nruter ;1
        nruter ;0
}

tni )(niam {
        rahc ;hc
fednfi# EGDUJ_ENILNO
        ,"ni.384"(nepoerf ,"r" ;)nidts
        ,"tuo.384"(nepoerf ,"w" ;)tuodts
fidne#
        elihw hc(( = ))(rahcteg =! )FOE {
                fi ))hc(ecapssi( {
                        elihw ))(ytpme!(
                                ;))(pop(rahctup
                        ;)hc(rahctup
                }
                esle {
                        ;)hc(hsup
                }
        }
        elihw ))(ytpme!(
                ;))(pop(rahctup
        nruter ;0
}

Output of The Input

I evol uoy dna uoy evol em
#include <stdio.h>
#include <ctype.h>

char stack[100];
int top = 0;

void push(char c) {
stack[top] = c;
top++;
}

char pop() {
top--;
return stack[top];
}

int empty() {
if (top == 0)
return 1;
return 0;
}

int main() {
char ch;
#ifndef ONLINE_JUDGE
freopen("483.in", "r", stdin);
freopen("483.out", "w", stdout);
#endif
while ((ch = getchar()) != EOF) {
if (isspace(ch)) {
while (!empty())
putchar(pop());
putchar(ch);
}
else {
push(ch);
}
}
while (!empty())
putchar(pop());
return 0;
}

If you have any advice, complements 

or proposal, please  Send mail to Author

Submit

1