2、输入一行字符,统计有多少个单词。
2、输入一行字符,统计有多少个。
什么是分割的标志? 这里用的 ' ' '\t' '.' 最多输入多少个字符? 现在是100 不符合要求的具体细节让你朋友自己按要求改改。 #include #define SIZE 100 void main() { char s[100]; int i; int num = 0; int word = 0; char c; gets(s); for (i = 0; (c = s[i]) != '\0'; i++) { if (c == ' ' || c == '\t' || c == '.') word = 0; else if (word == 0) { word = 1; num++; } } printf("result:%d\n", num); }