标签:lag std amp oid NPU class flag put main
#include<stdio.h> #include<string.h> int fun(char *s) { int count=0; int flag=0; //声明标志 while(*s!=‘\0‘) { if(*s!=‘ ‘ && flag==0) { count++; flag=1; } if(*s==‘ ‘) //当字符串出现空格,将flag置0,则可进入第一个if语句,单词个数加1 flag=0; s++; } return count; } void main() { char s[81]; printf("Please input a string:"); gets(s); printf("The string have %d word\n",fun(s)); }
标签:lag std amp oid NPU class flag put main
原文地址:https://www.cnblogs.com/-slz-2/p/11260292.html