View Code of Problem 58

#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string h;
	getline(cin,h);
	int num=0;
	bool f=true;
	for(int i=0;i<h.length();i++)
	{
		if(h[i]!=' ')
		{
			if(f)
			{
				f=false;
				num++;	
			}
		
		}
		else
		{
			f=true;
		} 
	}
	cout<<num;
	return 0;
}

Double click to view unformatted code.


Back to problem 58