View Code of Problem 58

#include<iostream>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iomanip>
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.


Back to problem 58