Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- struct Date{
- int day;
- int month;
- int year;
- int index;
- bool operator<(const Date& d) const {
- if(year < d.year) return true;
- else if( year > d.year) return false;
- else{
- if(month < d.month) return true;
- else if(month > d.month) return false;
- else{
- if(day < d.day) return true;
- return false;
- }
- }
- }
- Date(){
- }
- Date(int d, int m, int y, int i): day(d), month(m), year(y), index(i) {
- }
- };
- // std::vector<Date> dates;
- int main() {
- Date dates[100] = {};
- int n;
- scanf("%d", &n);
- for(int i = 0; i < n; ++i){
- int d, m, y;
- scanf("%d.%d.%d", &d, &m, &y);
- dates[i] = Date(d, m, y, i + 1);
- }
- std::sort(dates, dates + n, [](const Date& a, const Date& b){
- if(a < b){
- return true;
- }
- return false;
- });
- for(int i = 0; i < n; ++i){
- printf("%d\n", dates[i].index);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement