View Code of Problem 58

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

Double click to view unformatted code.


Back to problem 58