Advertisement
wojiaocbj

T

Jun 12th, 2022
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #pragma warning(disable:4996)
  7. char buffer[100][1020] = {0};
  8. void reverse(char *str){
  9.     int n = strlen(str);
  10.     char tmp = 0;
  11.     int lb = 0,ub = n - 1;
  12.     while(lb < ub){
  13.         tmp = str[lb];str[lb] = str[ub];str[ub] = tmp;
  14.         lb++;ub--;
  15.     }
  16. }
  17. int main(int argc,char **argv){
  18.     FILE *fp2 = fopen("out2.txt","w");
  19.     int cur = 0;
  20.     while(gets(buffer[cur])){
  21.         reverse(buffer[cur]);
  22.         cur++;
  23.     }
  24.     while(cur--){
  25.         puts(buffer[cur]);
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement