Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- struct Student {string name, secname; int day, month, year;};
- bool isFirstGreater(const vec& first, const vec& second)
- {
- if (first.year > second.year) {
- return true;
- } else if (first.year == second.year) {
- if (first.month > second.month) {
- return true;
- } else if (first.month == second.month) {
- if (first.day > second.day) {
- return true;
- } else if (first.day == second.day) {
- if (first.secname > second.secname) {
- return true;
- } else if (first.name >= second.name) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- }
- if (first.month > second.month) {
- if (first.day > second.day) {
- }
- }
- return true;
- if(first.age == second.age)
- return first.name<second.name;
- return false;
- }
- int main() {
- int n;
- cin >> n;
- string name, secname;
- int day, month, year;
- vector<Student> vec;
- for (int i = 0; i < n; ++i) {
- cin >> name >> secname >> day >> month >> year;
- vec.push_back({ name, secname, day, month, year });
- }
- string command;
- cin >> command;
- int key;
- for (int i = 0; i < vec.size(); ++i) {
- if (command == "name") {
- sort(vec.secname.begin(), vec.secname.end(), isFirstGreater);
- } else if (command == "date") {
- cout << vec[key - 1].day << "." << vec[key - 1].month << "." <<
- vec[key - 1].year << "\n";
- }
- }
- for (int i = 0; i < vec.size(); ++i) {
- cout << vec[i].name << " " << vec[i].secname << " ";
- cout << vec[i].day << "." << vec[i].month << "." << vec[i].year << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement