Question
in C++.....Write a program which sorts 5 students by the year of their enrollment in university So if i Input ID Name year of study
in C++.....Write a program which sorts 5 students by the year of their enrollment in university
So if i Input
ID Name year of study
1 | Smith | Mary | 3 |
2 | Jones | Sophie | 1 |
3 | Williams | Mary | 4 |
4 | Brown | Anne | 2 |
5 | Taylor | Joana | 5 |
The output should be
ID Name year of study
1 | Jones | Sophie | 1 |
2 | Brown | Anne | 2 |
3 | Smith | Mary | 3 |
4 | Williams | Mary | 4 |
5 | Taylor | Joana | 5 |
Use indications given below
-use sort function from STL
-use following pseudocode
struct Node{
int ID;
char name[50];
int year;
};
-use Standard Template Library:
list
-insert data in TheList ( at the back)
Node el;
el.ID=1;
strcpy(el.name,"name 1");
el.year=1;
lista.push_back(el);
- print elements in the list
for(std::list
cout << "ID: " << it->ID << " nume: " << it->nume << " an: "<< it->an << endl;
}
- insert data into the list(at the begining, at the end)
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