View Code of Problem 58

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

Double click to view unformatted code.


Back to problem 58