#include <iostream>
#include <string.h>
using namespace std;
#define MAX 300
int myStrcmp(char s1[], char s2[]);
int myStrlen(char s[], int k);
void myStrcpy(char s[], int vt, char s1[], int k);
void mySubstr(char s[], int b, int count, char ss[]);
bool myStrcat(char s1[], char s2[]);
void StringReverse(char st[]);
int main()
{
char s[MAX];
cin.getline(s,MAX);
if (myStrcmp(s, "") == 0)
cout << "Chuoi rong." << endl;
else
{
StringReverse(s);
cout << s << endl;
}
return 0;
}
int myStrlen(char s[], int k){
int dem = 0;
for (int i=0;s[i]!='\0';i++) ++dem;
return dem;
}
void rever(char s[],int st, int ed){
//cout << st << " " << ed << endl;
for (int i = 0 ; i<= (ed-st)/2 ; i++) {
char temp = s[st+i];
s[st+i] = s[ed-i];
s[ed-i] = temp;
}
}
void StringReverse(char s[]){
int i = 0;
while (i<myStrlen(s,0)){
while (s[i]==' '&&i<myStrlen(s,0)) {
//cout << s[i];
++i;
}
int strt = i;
while (s[i]!=' '&&i<myStrlen(s,0)) ++i;
if (strt<myStrlen(s,0)){
if (i<myStrlen(s,0)) rever(s,strt,i-1);
else rever(s,strt,myStrlen(s,0)-1);
//cout << s << endl;
}
}
}
int myStrcmp(char s1[], char s2[]){
bool check_space = false;
if (myStrlen(s1,0)-1==0) return 0;
//cout << myStrlen(s1,0) << endl;
for (int i=0;i<myStrlen(s1,0)-1;i++) if (s1[i]!=' ') check_space=true;
if (check_space==false) return 0; // chuoi toan dau cach
return 1;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgTUFYIDMwMAoKaW50IG15U3RyY21wKGNoYXIgczFbXSwgY2hhciBzMltdKTsKaW50IG15U3RybGVuKGNoYXIgc1tdLCBpbnQgayk7CnZvaWQgbXlTdHJjcHkoY2hhciBzW10sIGludCB2dCwgY2hhciBzMVtdLCBpbnQgayk7CnZvaWQgbXlTdWJzdHIoY2hhciBzW10sIGludCBiLCBpbnQgY291bnQsIGNoYXIgc3NbXSk7CmJvb2wgbXlTdHJjYXQoY2hhciBzMVtdLCBjaGFyIHMyW10pOwp2b2lkIFN0cmluZ1JldmVyc2UoY2hhciBzdFtdKTsKCmludCBtYWluKCkKewoJY2hhciBzW01BWF07CgljaW4uZ2V0bGluZShzLE1BWCk7CglpZiAobXlTdHJjbXAocywgIiIpID09IDApCgkJY291dCA8PCAiQ2h1b2kgcm9uZy4iIDw8IGVuZGw7CgllbHNlCgl7CgkJU3RyaW5nUmV2ZXJzZShzKTsKCQljb3V0IDw8IHMgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9CgppbnQgbXlTdHJsZW4oY2hhciBzW10sIGludCBrKXsKICAgIGludCBkZW0gPSAwOwogICAgZm9yIChpbnQgaT0wO3NbaV0hPSdcMCc7aSsrKSArK2RlbTsKICAgIHJldHVybiBkZW07Cn0KCgp2b2lkIHJldmVyKGNoYXIgc1tdLGludCBzdCwgaW50IGVkKXsKICAgIC8vY291dCA8PCBzdCA8PCAiICIgPDwgZWQgPDwgZW5kbDsKICAgIGZvciAoaW50IGkgPSAwIDsgaTw9IChlZC1zdCkvMiA7IGkrKykgewogICAgICAgIGNoYXIgdGVtcCA9IHNbc3QraV07CiAgICAgICAgc1tzdCtpXSA9IHNbZWQtaV07CiAgICAgICAgc1tlZC1pXSA9IHRlbXA7CiAgICB9Cn0KCgp2b2lkIFN0cmluZ1JldmVyc2UoY2hhciBzW10pewoKCiAgICBpbnQgaSA9IDA7CiAgICB3aGlsZSAoaTxteVN0cmxlbihzLDApKXsKICAgICAgICB3aGlsZSAoc1tpXT09JyAnJiZpPG15U3RybGVuKHMsMCkpIHsKICAgICAgICAgICAgICAgIC8vY291dCA8PCBzW2ldOwogICAgICAgICAgICAgICAgKytpOwogICAgICAgIH0KICAgICAgICBpbnQgc3RydCA9IGk7CiAgICAgICAgd2hpbGUgKHNbaV0hPScgJyYmaTxteVN0cmxlbihzLDApKSArK2k7CgogICAgICAgIGlmIChzdHJ0PG15U3RybGVuKHMsMCkpewoKICAgICAgICBpZiAoaTxteVN0cmxlbihzLDApKSByZXZlcihzLHN0cnQsaS0xKTsKICAgICAgICBlbHNlIHJldmVyKHMsc3RydCxteVN0cmxlbihzLDApLTEpOwogICAgICAgIC8vY291dCA8PCBzIDw8IGVuZGw7CiAgICAgICAgfQoKICAgIH0KCn0KCgppbnQgbXlTdHJjbXAoY2hhciBzMVtdLCBjaGFyIHMyW10pewogICAgYm9vbCBjaGVja19zcGFjZSA9IGZhbHNlOwogICAgaWYgKG15U3RybGVuKHMxLDApLTE9PTApIHJldHVybiAwOwogICAgLy9jb3V0IDw8IG15U3RybGVuKHMxLDApIDw8IGVuZGw7CiAgICBmb3IgKGludCBpPTA7aTxteVN0cmxlbihzMSwwKS0xO2krKykgaWYgKHMxW2ldIT0nICcpIGNoZWNrX3NwYWNlPXRydWU7CiAgICBpZiAoY2hlY2tfc3BhY2U9PWZhbHNlKSByZXR1cm4gMDsgLy8gY2h1b2kgdG9hbiBkYXUgY2FjaAogICAgcmV0dXJuIDE7Cgp9