View Code of Problem 58

#include<bits/stdc++.h>
using namespace std;

int main()
{
    string c;
    getline(cin, c);
    int count=0;
    for (int i = 0; i < c.size(); i++) {
	   if (c[i] == ' '&&c[i - 1] != ' ')
		  count++;
    }
    cout << count;

    return 0;
}

Double click to view unformatted code.


Back to problem 58