#include<iostream> #include<malloc.h> #include<algorithm> #include<cstring> using namespace std; int main() { char s[999]; gets(s); int k=0; for(int i=0;s[i]!='\0';i++) { if(s[i]!=' '&&s[i+1]==' ') k++; } if(s[strlen(s)-1]!=' ')k++; cout<<k; return 0; } |
Double click to view unformatted code.