Advertisement
Matqux

A3

Oct 30th, 2019
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. change(char *be, char *ki, int n)
  4. {
  5.     int sz = 0;
  6.     int k = 0;
  7.  
  8.     for (int i = 0; be[i] != '\n'; i++)
  9.     {
  10.         if (sz % n == 0)
  11.         {
  12.             ki[k] = be[i];
  13.             k++;
  14.         }
  15.         if (be[i] == ' ')
  16.         {
  17.             sz++;
  18.         }
  19.     }
  20.     ki[k-1] = '\0';
  21.  
  22. }
  23.  
  24. int main()
  25. {
  26.     char ch[50];
  27.     char chki[50];
  28.  
  29.     fgets(ch, 50, stdin);
  30.  
  31.     change(ch, chki, 3);
  32.  
  33.     printf("%s", chki);
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement