View Code of Problem 58

#include<stdio.h>
#include<string.h>

int main() {
	char s[100];
	gets(s);
	int count = 0;
	int i = 0;
	while (s[i] != '\0') {
		if((s[i] == ' ')&&(s[i+1] != ' '))
			count++;
		i++;
	}
	if (s[i - 1] != ' ')
		count++;
	printf("%d\n", count);


}

Double click to view unformatted code.


Back to problem 58