View Code of Problem 58

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

Double click to view unformatted code.


Back to problem 58