Advertisement
kachamaka

Untitled

Mar 9th, 2022
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. struct Date{
  6. int day;
  7. int month;
  8. int year;
  9. int index;
  10.  
  11. bool operator<(const Date& d) const {
  12. if(year < d.year) return true;
  13. else if( year > d.year) return false;
  14. else{
  15. if(month < d.month) return true;
  16. else if(month > d.month) return false;
  17. else{
  18. if(day < d.day) return true;
  19. return false;
  20. }
  21. }
  22. }
  23.  
  24. Date(){
  25.  
  26. }
  27.  
  28. Date(int d, int m, int y, int i): day(d), month(m), year(y), index(i) {
  29.  
  30. }
  31. };
  32.  
  33. // std::vector<Date> dates;
  34.  
  35. int main() {
  36. Date dates[100] = {};
  37. int n;
  38. scanf("%d", &n);
  39. for(int i = 0; i < n; ++i){
  40. int d, m, y;
  41. scanf("%d.%d.%d", &d, &m, &y);
  42. dates[i] = Date(d, m, y, i + 1);
  43. }
  44.  
  45. std::sort(dates, dates + n, [](const Date& a, const Date& b){
  46. if(a < b){
  47. return true;
  48. }
  49. return false;
  50. });
  51. for(int i = 0; i < n; ++i){
  52. printf("%d\n", dates[i].index);
  53. }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement