View Code of Problem 58

#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	int count=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=' '&&(i==s.size()-1||s[i+1]==' ')){
			count++;
		} 
	}
	cout<<count;
} 

Double click to view unformatted code.


Back to problem 58