Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. struct Student {string name, secname; int day, month, year;};
  9.  
  10. bool isFirstGreater(const vec& first, const vec& second)
  11. {
  12. if (first.year > second.year) {
  13. return true;
  14. } else if (first.year == second.year) {
  15. if (first.month > second.month) {
  16. return true;
  17. } else if (first.month == second.month) {
  18. if (first.day > second.day) {
  19. return true;
  20. } else if (first.day == second.day) {
  21. if (first.secname > second.secname) {
  22. return true;
  23. } else if (first.name >= second.name) {
  24. return true;
  25. } else {
  26. return false;
  27. }
  28. } else {
  29. return false;
  30. }
  31. }
  32. }
  33.  
  34.  
  35. if (first.month > second.month) {
  36. if (first.day > second.day) {
  37. }
  38. }
  39. return true;
  40. if(first.age == second.age)
  41. return first.name<second.name;
  42. return false;
  43. }
  44.  
  45. int main() {
  46. int n;
  47. cin >> n;
  48. string name, secname;
  49. int day, month, year;
  50. vector<Student> vec;
  51. for (int i = 0; i < n; ++i) {
  52. cin >> name >> secname >> day >> month >> year;
  53. vec.push_back({ name, secname, day, month, year });
  54. }
  55. string command;
  56. cin >> command;
  57. int key;
  58. for (int i = 0; i < vec.size(); ++i) {
  59. if (command == "name") {
  60. sort(vec.secname.begin(), vec.secname.end(), isFirstGreater);
  61. } else if (command == "date") {
  62. cout << vec[key - 1].day << "." << vec[key - 1].month << "." <<
  63. vec[key - 1].year << "\n";
  64. }
  65. }
  66. for (int i = 0; i < vec.size(); ++i) {
  67. cout << vec[i].name << " " << vec[i].secname << " ";
  68. cout << vec[i].day << "." << vec[i].month << "." << vec[i].year << "\n";
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement