View Code of Problem 58

#include<stdio.h>
#include<string.h>
int main(){
	char str[1000];
	gets(str);
	int flag=1;
	int count=0;
	for(int i=0;i<strlen(str);i++){
		if(str[i]==' '&&flag==1){
			count++;
			flag=0;
		}else if(str[i]!=' '){
			flag=1;
		}
		
	}
	printf("%d",count);
	
	return 0;
}

Double click to view unformatted code.


Back to problem 58