diff --git a/C/sttring.c b/C/sttring.c new file mode 100644 index 0000000..63c12fb --- /dev/null +++ b/C/sttring.c @@ -0,0 +1,31 @@ +#include +#include + +void reverse(char*, int, int); + +int main() +{ + char a[100]; + + gets(a); + + reverse(a, 0, strlen(a)-1); + + printf("%s\n", a); + + return 0; +} + +void reverse(char *x, int begin, int end) +{ + char c; + + if (begin >= end) + return; + + c = *(x+begin); + *(x+begin) = *(x+end); + *(x+end) = c; + + reverse(x, ++begin, --end); +} \ No newline at end of file