Advertisement
a53

qclasa

a53
Oct 13th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. struct elev
  4. {
  5. int cod,info,abse;
  6. };
  7. elev a[40],max1,max2;
  8. int n,med,nr10;
  9.  
  10. int main()
  11. {
  12. ifstream f("qclasa.in");
  13. f>>n;
  14. f>>a[0].cod>>a[0].info>>a[0].abse;
  15. if(a[0].info==10)
  16. ++nr10;
  17. med+=a[0].info;
  18. max1=max2=a[0];
  19. for(int i=1;i<n;++i)
  20. {
  21. f>>a[i].cod>>a[i].info>>a[i].abse;
  22. if(a[i].info==10)
  23. ++nr10;
  24. med+=a[i].info;
  25. if(a[i].abse>max1.abse||(a[i].abse==max1.abse&&a[i].cod<max1.cod))
  26. max2=max1,max1=a[i];
  27. else
  28. if(a[i].abse>max2.abse||(a[i].abse==max2.abse&&a[i].cod<max2.cod))
  29. max2=a[i];
  30. }
  31. f.close();
  32. ofstream g("qclasa.out");
  33. g<<nr10<<'\n'<<med/n<<'\n';
  34. g<<max1.cod<<' '<<max1.info<<' '<<max1.abse<<'\n'<<max2.cod<<' '<<max2.info<<' '<<max2.abse;
  35. g.close();
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement