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.
Easy C++ code || Class and Objects || With Proper guidlines
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;classStudent{private:intscore1,score2,score3,score4,score5;public:voidinput(intscore1,intscore2,intscore3,intscore4,intscore5){this->score1=score1;this->score2=score2;this->score3=score3;this->score4=score4;this->score5=score5;}intcalculateTotalScore(){returnthis->score1+this->score2+this->score3+this->score4+this->score5;}};intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intn;cin>>n;ints1,s2,s3,s4,s5;cin>>s1>>s2>>s3>>s4>>s5;StudentKristen;Kristen.input(s1,s2,s3,s4,s5);intKristenScore=Kristen.calculateTotalScore();intcnt=0;n--;while(n-->0){Studentothers;cin>>s1>>s2>>s3>>s4>>s5;others.input(s1,s2,s3,s4,s5);if(others.calculateTotalScore()>KristenScore)cnt++;}cout<<cnt;return0;}
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 →
Easy C++ code || Class and Objects || With Proper guidlines