int month,day,year;
cout << "Enter date:" << endl;
cin >> year >> month >> day;
bool correct=false;
if (month > 0 && month <= 12)
{
if (!correct)
{
cout << "Enter date:" << endl;
cin >> year >> month >> day;
bool correct=false;
if (month > 0 && month <= 12)
{
switch (month)}
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if (day <= 31)case 2:
correct=true;break;
if ((day <= 29 && year % 4 == 0) || (day <= 28 && year % 4 != 0))case 4:
correct = true;break;
case 6:
case 9:
case 11:
if (day <= 30)
correct = true;break;
default:
break;}
if (!correct)
cout << "Incorrect date!" << endl;else
{
if (day == 31 && month == 12)}
{
day = 1;}
month = 1;
year++;
else if (
(day == 31 && (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10)){
|| (day == 30 && (month == 4 || month == 6 || month == 9 || month == 11))
|| (month == 2 && (day == 28 || day == 29))
)
month++;}
day = 1;
else
day++;
cout << day << " day " << month << " month " << year << " year" << endl;
Комментариев нет:
Отправить комментарий