View Code of Problem 58

#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	char str[100];
	gets(str);
	int sum = 0;
	int mark = 1;
	int len=strlen(str);
	for (int i = 0; i < len; i++) {
		if (str[i] != ' '&&mark==1) {
			sum++;
			mark = 0;
		}
		else if(str[i]==' ') {
			mark = 1;
		}
	}
	cout << sum;
	return 0;
}

Double click to view unformatted code.


Back to problem 58