View Code of Problem 58

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    char str[100];
    gets(str);

    int numbers = 0;
    int flag =0;

    for(int i=0;str[i]!='\0';i++){
        //cout<<str[i];
        if(str[i] != ' ' && flag == 0){
            flag = 1;
            numbers++;

        }
        else if(str[i] == ' '){
            flag = 0;
        }
    }
    cout<<numbers;
    return 0;
}

Double click to view unformatted code.


Back to problem 58