Advertisement
mario_mos

tabreverse

Jul 25th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. #include <string.h>
  6. char invtab(char arr[])
  7. {
  8. int longueur = strlen(arr);
  9. char tmp;
  10. char tmp2;
  11.  
  12. for(int i = 0 ; i < longueur ; i++)
  13. {
  14.  
  15. tmp = arr[i];
  16. tmp2 = arr[ longueur - i - 1];
  17. arr[i]= tmp2;
  18. arr[ longueur - i - 1] = tmp;
  19. if(i == 2) printf("tab miparcourt %s\n",arr);
  20.  
  21.  
  22.  
  23. // printf("arr[i] %c\n",arr[i]);
  24. // printf("tmp %c\n",tmp);
  25. // printf("tmp2 %c\n",tmp2);
  26. // printf("arr[ longueur - i - 1]; %c\n",arr[ longueur - i - 1]);
  27.  
  28.  
  29.  
  30. }
  31.  
  32.  
  33. }
  34.  
  35. int main()
  36. {
  37.  
  38. char arr[]="maman";
  39. //char arr2[] ="salut";
  40. invtab(arr);
  41. printf("Avec tableau : %s\n",arr);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement