View Code of Problem 58

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

Double click to view unformatted code.


Back to problem 58