#include<stdio.h> #include<string.h> int main(){ char str[80]; gets(str); //输入只有一行句子。仅有空格和英文字母构成。 ___qweqew____qwe___qwe__ int i,flag,count; i = 0; flag = 0; count = 0; while(str[i]){ //printf("1"); if(str[i]==' ') flag = 0; else if('a'<=str[i]<='z'||'A'<=str[i]<='Z'){ //printf("%c",str[i]); if(!flag) count++; flag = 1; } //else{ // flag = 0; //} i++; } printf("%d",count); return 0 ; } |
Double click to view unformatted code.