View Code of Problem 58

#include<stdio.h>
#include<math.h>
#include <string.h>
#define Max 1000
int main()
{
	char str[Max];
	gets(str);
	int i,cnt=0,word=0;
	for(i=0;i<strlen(str);i++)
	{
		if(str[i]==' ')
		{
		   word=0;	
		}
		else if(word==0)
		{
			word=1;cnt++;
		}	  
	}
	printf("%d",cnt);
	return 0;
	
}

Double click to view unformatted code.


Back to problem 58