123456
struct date { int date; int month; int day; };
12345
date mydate[10]; for(int i=0; i<10; i++) { mydate[i]{date1,month1,day1}; }
123456789101112131415161718192021222324252627282930313233343536
#include <algorithm> #include <iostream> #include <vector> struct date { int year; int month; int day; }; std::istream& operator>>(std::istream& in, date& d) { return in >> d.year >> d.month >> d.day; } std::ostream& operator<<(std::ostream& out, const date& d) { return out << d.year << ' ' << d.month << ' ' << d.day; } int main() { std::vector<date> data; date temp; while(std::cin >> temp) data.push_back(temp); for(const auto d: data) std::cout << d << '\n'; std::cout << '\n'; //Sort by year std::sort(data.begin(), data.end(), [](const date& lhs, const date& rhs) { return lhs.year < rhs.year; }); for(const auto d: data) std::cout << d << '\n'; }