Advertisement
yanni_yagami

Untitled

Jul 18th, 2020
998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void)
  5. {
  6.   int i, j, k, half;
  7.   char str[256], finlaStr[256];
  8.   scanf("%s", str);
  9.  
  10.   half = strlen(str)/2;
  11.  
  12.   if(strlen(str) % 2) j = half+1;
  13.   else j = half;
  14.  
  15.   for(i = 0, k = 0; i < half; i++, j++, k += 2)
  16.   {
  17.     finlaStr[k] = str[i];
  18.     finlaStr[k+1] = str[j];
  19.   }
  20.  
  21.   if(strlen(str) % 2)
  22.   {
  23.     finlaStr[k] = str[i];
  24.     finlaStr[k+1] = '\0';
  25.   }
  26.   else finlaStr[k] = '\0';
  27.  
  28.  
  29.   printf("%s\n", finlaStr);
  30.  
  31.   return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement