#include<iostream> #include<string.h> using namespace std; int main() { char str[1000]; gets(str); int len=strlen(str); int word,sum=0; for(int i=0;i<len;i++) { if(str[i]==' ') word=0; else if(word==0) { word=1; sum++; } } cout<<sum<<endl; } |
Double click to view unformatted code.