View Code of Problem 58

#include <stdio.h>
#include <string.h>
#define N 81
int main()
{
	char a[N];
	int i, n;
	int k = 1;
	while(gets(a) != NULL)
	{
		n = strlen(a);
		for(i = 0; i < n - 1; i++)
		{
			if(a[i] == ' '&&a[i + 1] != ' ')
			{
				k++;
			}
		}
		printf("%d\n", k);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 58