Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- int cutWords()
- {
- char txt;
- int cnt=0,cntletter=0;
- for( txt=getchar(); txt!=EOF; txt=getchar())
- {
- if(cnt<5&&txt!=' ')
- {
- cnt++;
- putchar(txt);
- }
- if(txt==' '&&cnt<=5)
- {
- putchar('\n');
- cnt=0;
- }
- if(cnt==6 && (txt==' '||txt=='\n'))
- {
- putchar('\n');
- cnt=0;
- cntletter++;
- }
- if(txt==' '&&(txt=getchar())!=' ')
- {
- putchar(txt);
- cnt++;
- }
- }
- if(cnt==6)
- ++cntletter;
- return cntletter;
- }
- int main()
- {
- printf("%d\n",cutWords());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement