#include<stdio.h>
int main(){
char a[1000] = {0};
while(gets(a) != NULL){
int number = 0 ;
int i = 0;
for(i = 0; a[i] != 0; i++){
if((a[i] >= 'A' && a[i] <= 'Z') || ( a[i] >= 'a' && a[i] <= 'z')){
number++;
for(; (a[i] != ' ' && a[i] != 0) ; i++){
;
}
}
}
printf("%d\n",number);
for(i = 0; a[i] != 0;i++){
a[i] = 0;
}
}
return 0;
}
此题为求单词数
for(i = 0; a[i] != 0;i++){
a[i] = 0;
}
其中这步我不太明白,为什么要有,如果去掉的话就是Compile Error 麻烦大家了