|
假定每个单词用空格隔开。
例子:
输入:how are you!
输出:3
两种方法:
一:
#include
#include
#define SIZE 20 int 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 20 int 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
|