View Code of Problem 58

#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[1000];
	int i = 0,sum = 0;
	gets(a);
	if(a[0]!=' ')sum++;
	for(int i = 0;i<strlen(a)-1;i++){
		if(a[i]==' '&&a[i+1]!=' ')sum++;
	}
	printf("%d",sum);
	return 0;
} 

Double click to view unformatted code.


Back to problem 58