Advertisement
AJTAMjid2000

Exercise 1.22

Jun 17th, 2021
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.     int c,i=0,j=0,k=0;
  6.     char ch[1000][1000];
  7.     while((c=getchar())!=EOF)
  8.     {
  9.  
  10.         if(c!='\n')
  11.         {
  12.             ch[i][j]=c;
  13.          
  14.          
  15.                 j++;
  16.                 i=0;
  17.         }
  18.         else
  19.         {
  20.             i++;
  21.            // j=0;
  22.            
  23.         }
  24.  
  25.     }
  26.     for(j=0;j<i;j++)
  27.     {
  28.         if(strlen(ch[j])>=30)
  29.         {
  30.             for(k=0;k<strlen(ch[j]);k++)
  31.             {
  32.                 if(k>=20 && ch[j][k]==' ')
  33.                 {
  34.                     printf("\n");
  35.                 }
  36.  
  37.                 printf("%c",ch[j][k]);
  38.             }
  39.  
  40.                 printf("\n");
  41.  
  42.  
  43.             }
  44.         else
  45.         {
  46.             printf("%s\n",ch[j]);
  47.         }
  48.  
  49.  
  50.    }
  51.  
  52.     return 0;
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement