Question
In C++ programming language: Write the program to read the list of the e_xams with details about the problems and print it in the appropriate
Write the program to read the list of the e_xams with details about the problems and print it in the appropriate order.
Input
In the input, there is the list of N e_xams, where N is in the first line. Then, each data set (one e_xam) is in the form: in the first line, there is e_xam date (format: YYYY-MM-DD), e_xam name (letters, digits, and character '-'), and the number of problems (n). In the next n lines, there is a list of problems, in each line, there is a problem name and points for it. Please note that each date is different.
Output
Print information of each e_xam sorted by the date of the e_xam (earliest first). The list of problems should be also sorted, first by points (maximum first_, then in the case of the same number of points for the problem, sort them alphabetically (non-decreasing).
Remark
There are 5 test cases worth 1 point each. The first two cases are unhidden.Please note that all judges are case-sensitive (i.e., exact) judges. Time-limited is 1 second.
Template:
//Please note that writing anything (even a new line or whitespace) in any restricted part of the code will result in an error.
#include
#include
usingnamespacestd;
classEVENT{
private:
string date;
string name;
public:
EVENT(string da, string na) : date(da), name(na) { }
string GetDate() {returndate; }
void Info()
{
cout
cout
}
};
classPROBLEM{
private:
string name;
int points;
public:
PROBLEM(string n="", int p=0) : name(n), points(p) { }
string GetName() {returnname; }
int GetPoints() {returnpoints; }
void Info() { cout
};
classPROBLEMS{
private:
int number;// actual number of problems
PROBLEM tasks[100];// max number
public:
PROBLEMS(int n) : number(n) { }
void AddProblem(int i, PROBLEM& p) { tasks[i] = p; }
void Info() {for(int i=0;i;i++)>
void SortedInfo();
};
classE_XAM:publicEVENT,publicPROBLEMS {
public:
E_XAM(EVENT e, PROBLEMS p) : EVENT(e), PROBLEMS(p) {}
void Info()
{
EVENT(*this).Info();
PROBLEMS(*this).Info();
}
void SortedInfo();
};
void SortByDate(E_XAM**, int);
int main()
{
string date, name;
int num;
int ps;
E_XAM* list[100];// max. number of exams
cin >> num;
for(int i=0; i;>
{
cin >> date >> name >> ps;
E_XAM* e_xam =newE_XAM(EVENT(date,name),PROBLEMS(ps));
list[i] = e_xam;
for(int j=0; j;>
{
string name;
int pts;
cin >> name >> pts;
PROBLEM p(name,pts);
e_xam->AddProblem(j, p);
}
}
SortByDate(list,num);
for(int i=0; iSortedInfo();if(i)>;>
return0;
}
// begin: part 1, You are allowed to change the code ONLY between the brackets {} below in both methods
void SortByDate(E_XAM** list, int n)
{
}
void E_XAM::SortedInfo()
{
}
void PROBLEMS::SortedInfo()
{
}
// end: part 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started