View Code of Problem 58

#include "stdlib.h"
#include "algorithm"
#include "iostream"
#include <cstdio>
#include "string"
#include <iomanip>
#include <map>
#include "math.h"
using namespace std;
map<int, bool> mp;


int main()
{
	string str;
	getline(cin, str);
	int i = 0; int count = 0;
	int len = str.length();
	while (i < len)
	{
		while (str[i] == ' '&&i < len)i++;
		while (str[i] != ' '&&i < len)i++;
		count++;
	}
	cout << count;
	return 0;
}

Double click to view unformatted code.


Back to problem 58