View Code of Problem 58

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

	return 0;
}

Double click to view unformatted code.


Back to problem 58