Joao_Joao

Beecrowd 1235 - C

May 22nd, 2022 (edited)
438
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define f(i, s, t) for (int i = s; i < t; ++i)
  6. #define fd(i, t, s) for (int i = t; i >= s; --i)
  7.  
  8. int main() {
  9.   int n; scanf("%d", &n);
  10.   size_t size = 110;
  11.   char * p = (char*)malloc(size*sizeof(char));
  12.   getline(&p, &size, stdin);
  13.   f(i,0,n) {
  14.     getline(&p, &size, stdin);
  15.     p[strlen(p)-1] = '\n';
  16.     int a = strlen(p)/2, b = strlen(p) - a;
  17.     fd(j, a-1, 0) {
  18.       printf("%c", p[j]);      
  19.     }
  20.     fd(j, strlen(p)-2, b-1) {
  21.       printf("%c", p[j]);
  22.     }
  23.     printf("\n");
  24.   }
  25.   free(p), p = NULL;
  26. }
  27.  
RAW Paste Data Copied