View Code of Problem 58

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996);
#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 100000
int main()
{
	char a[N];
	gets(a);
	int i;
	int count = 0;
	int space=1;
	for (i = 0; i < strlen(a); i++)
	{
		if (a[i] != ' '&&space==1)
		{
			space = 0;
			count++;
		}
		if (a[i] == ' ')
			space = 1;		
	}
	printf("%d", count);
	return 0;
}

Double click to view unformatted code.


Back to problem 58