Classes and Objects

  • + 0 comments
    class student{
        public:
        int arr[5];
        
        int TotalScore(student a){
            int total=0;
            for(int i=0;i<5;i++)total+=arr[i];
            
            return total;
        }
    };
    int main() {
        int n;
        cin>>n;
        student Kristen;
        for(int i=0;i<5;i++){
            int temp;
            cin>>temp;
            Kristen.arr[i]=temp;
        }
        int KristenMarks=Kristen.TotalScore(Kristen);
        n--;
        int cnt=0;
        for(int i=1; i<=n;i++){
            student s;
            for(int i=0;i<5;i++){
                int temp;
                cin>>temp;
                s.arr[i]=temp;
            }
            int curr_marks=s.TotalScore(s);
            if(curr_marks>KristenMarks)cnt++;
        }
        cout<<cnt;
        return 0;
    }