#include<stdio.h> #include<string.h> int main() { char a[2000]; int count = 0; gets(a); int len = strlen(a); for (int i = 0; i <len; i++) { if ((a[i] >= 'a'&&a[i] <= 'z') || (a[i] >= 'A'&&a[i] <= 'Z')) { if (a[i + 1] == ' '||a[i+1]=='\0') count++; } } printf("%d\n", count ); return 0; } |
Double click to view unformatted code.