int fun( char *s)
{ //for循环遍历数组或者是while循环通过指针来遍历数组。
int i; //与取每一个的最后一个字母类似
int cnt=0; //注意for循环遍历的循环条件
for(i=0;s[i]!='\0';i++)
{
if(s[i]!=' '&&(s[i+1]==' '||s[i+1]=='\0'))
{
cnt++;
}
}
return cnt;
}
C语言 精选真题20
最新推荐文章于 2025-07-23 22:59:22 发布