View Code of Problem 58

#include<stdio.h>
#include<string.h>
int main()
{
	int i,flag=0,count=0;
	char str[100];
	gets(str);
	if(strlen(str)) count=1;
	for(i=0;str[i]!='\0';i++)
	{
		if(str[i]!=' ')
		{
			flag=1;
		}
		else if(flag==1)
		{
			flag=0;	
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Double click to view unformatted code.


Back to problem 58