View Code of Problem 58

#include <iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

	char arr[1000];
	gets(arr);	
	int i=0;
	int s = 0;
	int count = 0;
	while( arr[i] != '\0'){
		
		if(arr[i] != ' '){
			if( s == 0)
				count++;
			s  = 1;
		}else{
			s = 0;
		}
		i++;
	}
	printf("%d\n" , count);
	
	return 0 ;
}












Double click to view unformatted code.


Back to problem 58