4.3

#include <stdio.h>
int main()
{
    char string[100];
    int i,num=0,word=0;
    char c;
    gets(string);
    for(i=0;(c=string[i])!='\0';i++)
        if(c==' ') word=0;
        else if(word==0)
        {
            word=1;
            num++;
        }
    printf("There are %d words in this line.\n",num);
 return 0;
}

 

posted on 2019-06-22 19:49  an同学  阅读(172)  评论(0)    收藏  举报

导航