View Code of Problem 58

#include<stdio.h>
#include<string.h>
#define N 10000
int main()
{
    char str[N];
    int n,i,flag=0,count=0;
    gets(str);
    n=strlen(str);
    for(i=0;i<n;i++)
    {
        if(str[i]==' ')
           {
               while(str[++i]==' ');
               flag=0;
           }
        else
           {
            if(flag==0)
               {
                   count++;
                   flag=1;
               }
           }

    }
    printf("%d",count);
    return 0;
}

Double click to view unformatted code.


Back to problem 58