Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- #include <numeric>
- #include <algorithm>
- using namespace std;
- struct Student {
- int scores[5];
- int n;
- Student(){
- };
- void fillScores(int(& arr)[5]){
- for(int i=0;i<5;i++)
- scores[i]=arr[i];
- };
- int calculateTotalScore() const
- {
- return accumulate(scores,scores+5,0);
- };
- void print() const
- {
- for(int i=0;i<5;i++)
- cout<<scores[i]<<" ";
- };
- };
- int pero;
- bool vece(Student x)
- {
- if(x.calculateTotalScore()>=pero){return true;}
- else{return false;}
- }
- int main()
- {
- ifstream file("data.txt");
- int n;
- file>>n;
- int array[5];//bodovi
- Student* studenti=new Student[n];
- int j;
- for(j=0;j<n;j++)
- {
- for(int i=0;i<5;i++)
- {file>>array[i];}
- studenti[j].fillScores(array);
- //studenti[j].print();
- }
- // cout<<studenti[0].calculateTotalScore();
- pero=studenti[0].calculateTotalScore();
- cout<<count_if(studenti+1,studenti+n,vece);
- delete [] studenti;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement