Advertisement
simeonvarbanov

Untitled

Sep 11th, 2012
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. int reverse(char s[], int i, int j)
  3. {
  4.   int temp;
  5.   if(j == 1)
  6.     return 1;
  7.   else
  8.   temp = s[i];
  9.   s[i] = s[j];
  10.   s[j] = temp;
  11.   reverse(s, ++i, --j);
  12.   /* recursively i am calling the same function but
  13.   i am changing the values of the numbers*/
  14. }
  15. main()
  16. {  
  17. char text[] = "Hello";
  18. printf("Not reversed text: %s\n", text);
  19. reverse(text, 0, strlen(text)-1);
  20. printf("Reversed text: %s\n", text);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement