#include <string> #include <iostream> using namespace std; int main() { string a; getline(cin,a); int length=0,flag=0; for(int i=0;i<a.size();i++) { if(isalpha(a[i])&&flag==0) { flag=1; length++; } else if(a[i]==' ') { flag=0; } } printf("%d",length); system("pause"); return 0; } |
Double click to view unformatted code.