View Code of Problem 58

#include<stdio.h>
#include<string.h>
int main()
{
	char str[1000];
	gets(str);
	int i=0;
	int Isword=0;
	int count=0;
	while(str[i]!='\0')
	{
		if(str[i]>='a'&&str[i]<='z'||str[i]>='A'&&str[i]<='Z')
		{
			if(Isword==0)
			{
				count++;
				Isword=1;
				i++;
			}
			else
			{
				i++;
			}
		}
		else if(Isword==1)
		{
			Isword=0;
			i++;
		}
		else
		{
			i++;
		}
	}
	printf("%d",count);
	return 0;
}

Double click to view unformatted code.


Back to problem 58