SHARE
TWEET

Untitled

a guest Dec 29th, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void reverse(char *f, char *l){
  5.     char c = *f;
  6.     if(f != l+(strlen(l)-1)){
  7.         reverse(f+1, l);
  8.     }
  9.     *(l+(strlen(f)-1))=c;
  10. }
  11.  
  12. void main(){
  13.     char *s = "12345";
  14.     reverse(s, s);
  15.     printf("%s\n", s);
  16. }
  17.  
  18. and someone elses:
  19. void reverse(char *p, char *q)
  20. {
  21.     if(q + 1 == p || p == q)
  22.         return;
  23.     int c;
  24.     c = *p;
  25.     *p = *q;
  26.     *q = c;
  27.     reverse(p+1, q-1);
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top