#include <iostream>
#include <fstream>
using namespace std;
bool isLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
int daysInMonth(int month, int year) {
switch (month) {
case 4: case 6: case 9: case 11:
return 30;
case 2:
return isLeapYear(year) ? 29 : 28;
default:
return 31;
}
}
int main() {
ifstream infile("LONGDATE.inp");
ofstream outfile("LONGDATE.out");
int day, month, year;
infile >> day >> month >> year;
infile.close();
day += 2;
while (day > daysInMonth(month, year)) {
day -= daysInMonth(month, year);
month++;
if (month > 12) {
month = 1;
year++;
}
}
outfile << day << " " << month << " " << year << endl;
outfile.close();
return 0;
}
b thử run xem nha