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.
int scores[5];
void input(){
for(int i = 0; i<5;i++){
cin>>scores[i];
}
}
int calculateTotalScore(){
int sum = 0;
for(int i = 0; i<5;i++){
sum = sum+scores[i];
}
return sum;
}
};
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin>>n;
Student *st = new Student[n];
// int arr[3];
for(int i = 0; i<n;i++){
st[i].input();
}
int kristenscore;
kristenscore = st[0].calculateTotalScore();
int count = 0;
int total;
for (int i = 0;i<n; i++){
total = st[i].calculateTotalScore();
if(total>kristenscore){
count = count+1;
}
}
cout<<count;
return 0;
}
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 →
Solution of the problem is:
Code solution:
include
include
include
include
include
using namespace std;
class Student{ public:
};
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin>>n; Student *st = new Student[n]; // int arr[3];
}