Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. #include <numeric>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. struct Student {
  8. int scores[5];
  9. int n;
  10. Student(){
  11. };
  12. void fillScores(int(& arr)[5]){
  13. for(int i=0;i<5;i++)
  14. scores[i]=arr[i];
  15. };
  16. int calculateTotalScore() const
  17. {
  18. return accumulate(scores,scores+5,0);
  19. };
  20. void print() const
  21. {
  22. for(int i=0;i<5;i++)
  23. cout<<scores[i]<<" ";
  24. };
  25. };
  26. int pero;
  27. bool vece(Student x)
  28. {
  29. if(x.calculateTotalScore()>=pero){return true;}
  30. else{return false;}
  31. }
  32.  
  33.  
  34. int main()
  35. {
  36.  
  37.  
  38. ifstream file("data.txt");
  39. int n;
  40. file>>n;
  41.  
  42. int array[5];//bodovi
  43. Student* studenti=new Student[n];
  44. int j;
  45. for(j=0;j<n;j++)
  46. {
  47. for(int i=0;i<5;i++)
  48. {file>>array[i];}
  49. studenti[j].fillScores(array);
  50. //studenti[j].print();
  51. }
  52. // cout<<studenti[0].calculateTotalScore();
  53. pero=studenti[0].calculateTotalScore();
  54.  
  55.  
  56. cout<<count_if(studenti+1,studenti+n,vece);
  57.  
  58. delete [] studenti;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement