We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;classGrades{public:voidinput(intscore1,intscore2,intscore3,intscore4,intscore5){this->score1=score1;this->score2=score2;this->score3=score3;this->score4=score4;this->score5=score5;setSum(score1,score2,score3,score4,score5);}voidsetSum(intscore1,intscore2,intscore3,intscore4,intscore5){this->sum=this->score1+this->score2+this->score3+this->score4+this->score5;}intget_calculateSum(){returnthis->sum;}private:intscore1,score2,score3,score4,score5,sum;};intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */ints1,s2,s3,s4,s5,n;intcount=0;cin>>n;cin>>s1>>s2>>s3>>s4>>s5;GradesKristen;Kristen.input(s1,s2,s3,s4,s5);intKsum=Kristen.get_calculateSum();//cout << Ksum << endl;//should be 135for(inti=0;i<n-1;i++){Gradesothers;cin>>s1>>s2>>s3>>s4>>s5;others.input(s1,s2,s3,s4,s5);intOsum=others.get_calculateSum();//first one should be 140//second should be 120//cout << Osum << endl;if(Osum>Ksum){count++;}}cout<<count<<endl;return0;}/*inputs: 330 40 45 10 1040 40 40 10 1050 20 30 10 10*/
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Classes and Objects
You are viewing a single comment's thread. Return to all comments →