View Code of Problem 58

#include <bits/stdc++.h>
using namespace std;
#define N 10

int main()
{
	string str;
	while(getline(cin,str)) {
		int num=0;
		for(int i=0;i<=str.length();i++) {
			if(str[i-1]!=' '&& (str[i]==' '||str[i]=='\0') ) 
				num++;
		}
		cout<<num<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 58