samedi 28 décembre 2019

codeblocks keeps bringing out blank output for this code,what is wrong with it?

int main() 
{  
    vector temps;                                   
    for (double temp; cin>>temp; )   
        temps.push_back(temp);
    double sum = 0;
    double high_temp = 0;
    double low_temp = 0;
    for (int x : temps)  
    {          
        if(x > high_temp) 
            high_temp = x;       
        if(x < low_temp) 
            low_temp = x;           
        sum+=x;     
    }

    cout << "High temperature: " << high_temp<< '\n';           
    cout << "Low temperature: " << low_temp << '\n'; 
    cout << "Average temperature: " << sum/temps.size() << '\n'; 
}

Aucun commentaire:

Enregistrer un commentaire