Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define MAX_LENGHT 257
- int main()
- {
- int i=0,j=0,k=0,s=0;
- char str[MAX_LENGHT];
- fgets(str,MAX_LENGHT,stdin);
- while(str[i]=='\t'||str[i]==' '){
- i++;
- }
- while(str[i]!='\0'){
- if(str[0]==' '||str[0]=='\t'){
- if((str[i]!=' ')&&(str[i]!='\t')){
- j=i-1;
- s=0;
- while(((str[j]!='\t')&&(str[j]!=' ')&&(str[j]!='\0'))){
- j++;
- s++;
- }
- if(((str[j]=='\t')||(str[j]==' ')||(str[j]=='\0'))){
- k++;
- i++;
- }}}
- else{
- if((str[i]!=' ')&&(str[i]!='\t')){
- j=i;
- s=0;
- while(((str[j]!='\t')&&(str[j]!=' ')&&(str[j]!='\0'))){
- j++;
- s++;
- }
- if(((str[j]=='\t')||(str[j]==' ')||(str[j]=='\0'))){
- k++;}
- }
- else{
- i++;
- }
- }
- i=i+s;
- }
- printf("%d words",k);
- return 0;
- }
Add Comment
Please, Sign In to add comment