Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. int cutWords()
  5. {
  6. char txt;
  7.  
  8. int cnt=0,cntletter=0;
  9. for( txt=getchar(); txt!=EOF; txt=getchar())
  10. {
  11. if(cnt<5&&txt!=' ')
  12. {
  13. cnt++;
  14. putchar(txt);
  15. }
  16. if(txt==' '&&cnt<=5)
  17. {
  18. putchar('\n');
  19. cnt=0;
  20. }
  21.  
  22.  
  23.  
  24. if(cnt==6 && (txt==' '||txt=='\n'))
  25. {
  26. putchar('\n');
  27. cnt=0;
  28. cntletter++;
  29.  
  30. }
  31.  
  32. if(txt==' '&&(txt=getchar())!=' ')
  33. {
  34. putchar(txt);
  35. cnt++;
  36. }
  37.  
  38. }
  39.  
  40. if(cnt==6)
  41. ++cntletter;
  42. return cntletter;
  43. }
  44.  
  45. int main()
  46. {
  47. printf("%d\n",cutWords());
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement