fqrmix

123 -> 321 x2

Nov 4th, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #define length 81
  3. #include <stdlib.h>
  4. #include <string.h>
  5. char *reverse(char *mass, int n) {
  6.     if (n != 0) {
  7.         int i = 0;
  8.         int j = n - 1;
  9.         for (i = 0; i < j; i++) {
  10.             char c = *(mass + i);
  11.             *(mass + i) = *(mass + j);
  12.             *(mass + j) = c;
  13.             j--;
  14.         }
  15.     }
  16.  
  17.     return mass;
  18.  
  19. }
  20. int main()
  21. {
  22.     char s[length];
  23.     int n = 0, i = 0;
  24.     printf("Введите строку\n");
  25.     gets_s(s);
  26.     while (s[i] != '\0') {
  27.         n++;
  28.         i++;
  29.     }
  30.     reverse(s, n);
  31.     printf("%s\n", s);
  32.     system("pause");
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment