Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- using namespace std;
- struct Estudiant {
- int dni;
- string nom;
- double nota; // La nota Ês un valor entre 0 i 10, o -1 que representa NP
- bool repetidor;
- };
- const int NP = -1;
- void informacio(const vector<Estudiant>& es, double& min, double& max, double& mitj){
- min = max = mitj = NP;
- bool primer = true;
- int cont = 0;
- for (int i = 0; i < es.size(); ++i){
- if (!es[i].repetidor and es[i].nota != NP){
- if (primer){
- min = es[i].nota;
- max = es[i].nota;
- mitj = 0;
- primer = false;
- }
- if (es[i].nota > max) max = es[i].nota;
- if (es[i].nota < min) min = es[i].nota;
- mitj += es[i].nota;
- ++cont;
- }
- }
- if (cont != 0) mitj /= cont;
- cout << min << endl << max << endl << mitj << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement