#include<bits/stdc++.h> using namespace std; int main(){ string s; int i,t=0,c=0; getline(cin,s); for(i=0;i<s.length();i++){ if(s[i]==' ') t=1; else if(t==1){ t=0; c++; } } cout<<c; }
Double click to view unformatted code.