假定每一个单词用空格隔开。
样例:
输入:how are you!
输出:3
两种方法:
一:
#include另外一种:#include #define SIZE 20int main(){ char str[SIZE]={'\0'}; int count=0; printf("please input the string\n"); gets(str); puts(str); int length = strlen(str); for (int i=0;i
#include#include #define SIZE 20int main(){ char str[SIZE]={'\0'}; int count=0; int flag=0; printf("please input the string\n"); gets(str); puts(str); int length = strlen(str); for (int i=0;i