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