#include <iostream>
#include <string.h>
void reverse( char *s )
{
if ( !s )
return;
char *e = s + strlen( s ) - 1;
while ( s < e )
{
*e ^= *s;
*s ^= *e;
*e-- ^= *s++;
}
}
int main() {
// your code goes here
char* s1 = "123";
char* s2 = "";
std::cout << s1 << " - " << std::endl;
reverse(s1);
std::cout << s1 << std::endl;
std::cout << s2 << " - " << std::endl;
reverse(s2);
std::cout << s2 << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nLmg+Cgp2b2lkIHJldmVyc2UoIGNoYXIgKnMgKQp7CiAgICBpZiAoICFzICkKICAgICAgICByZXR1cm47CgogICAgY2hhciAqZSA9IHMgKyBzdHJsZW4oIHMgKSAtIDE7CiAgICB3aGlsZSAoIHMgPCBlICkKICAgIHsKICAgICAgICAqZSBePSAqczsKICAgICAgICAqcyBePSAqZTsKICAgICAgICAqZS0tIF49ICpzKys7CiAgICB9Cn0KaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgljaGFyKiBzMSA9ICIxMjMiOwoJY2hhciogczIgPSAiIjsKCQoJc3RkOjpjb3V0IDw8IHMxIDw8ICIgLSAiIDw8IHN0ZDo6ZW5kbDsKCXJldmVyc2UoczEpOwoJc3RkOjpjb3V0IDw8IHMxIDw8IHN0ZDo6ZW5kbDsKCQoJc3RkOjpjb3V0IDw8IHMyIDw8ICIgLSAiIDw8IHN0ZDo6ZW5kbDsKCXJldmVyc2UoczIpOwoJc3RkOjpjb3V0IDw8IHMyIDw8IHN0ZDo6ZW5kbDsKCXJldHVybiAwOwp9