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>#include<cassert>usingnamespacestd;classStudent{private:intgrades[5];public:voidinput(){for(inti=0;i<5;i++){cin>>grades[i];}}intcalculateTotalScore(){intsum=0;for(inti=0;i<5;i++){sum+=grades[i];}returnsum;}};intmain(){intn;// number of studentscin>>n;Student*s=newStudent[n];// an array of n studentsfor(inti=0;i<n;i++){s[i].input();}// calculate kristen's scoreintkristen_score=s[0].calculateTotalScore();// determine how many students scored higher than kristenintcount=0;for(inti=1;i<n;i++){inttotal=s[i].calculateTotalScore();if(total>kristen_score){count++;}}// print resultcout<<count;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 →