You are viewing a single comment's thread. Return to all comments →
#include <cmath> #include <cstdio> #include <iostream> using namespace std; class Student{ private: int scores[5]{}; public: void input(){ for (int i{}; i<5; i++) { std::cin >> scores[i]; } } int calculateTotalScore(){ int total{}; for (int i{}; i<5; i++) { total += scores[i]; } return total; } }; int main() { unsigned int n; std::cin >> n; Student st[n]; int n_g{}; for (size_t i{}; i<n; i++) { st[i].input(); (st[i].calculateTotalScore()>st[0].calculateTotalScore()) ? n_g++ : false; } std::cout << n_g; return 0; }
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 →