Advertisement
Guest User

Untitled

a guest
May 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. struct Estudiant {
  6. int dni;
  7. string nom;
  8. double nota; // La nota Ês un valor entre 0 i 10, o -1 que representa NP
  9. bool repetidor;
  10. };
  11.  
  12. const int NP = -1;
  13.  
  14. void informacio(const vector<Estudiant>& es, double& min, double& max, double& mitj){
  15. min = max = mitj = NP;
  16. bool primer = true;
  17. int cont = 0;
  18. for (int i = 0; i < es.size(); ++i){
  19. if (!es[i].repetidor and es[i].nota != NP){
  20. if (primer){
  21. min = es[i].nota;
  22. max = es[i].nota;
  23. mitj = 0;
  24. primer = false;
  25. }
  26. if (es[i].nota > max) max = es[i].nota;
  27. if (es[i].nota < min) min = es[i].nota;
  28. mitj += es[i].nota;
  29. ++cont;
  30. }
  31. }
  32. if (cont != 0) mitj /= cont;
  33. cout << min << endl << max << endl << mitj << endl;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement