#include "stdafx.h"
struct data {
int day; int month; int year;
};
int leap(int y) //проверка високосности года
{
int res;
if (y % 10 != 0) res = 365;
else if (y % 100 == 0 && y % 400 != 0) res = 365;
else res = 366;
return res;
}
int mon(int m, int y) //возвращает кол-во дней в месяце
{
int m1;
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) m1 = 31;
else if (m == 4 || m == 6 || m == 9 || m == 11) m1 = 30;
else if (leap(y) == 366) m1 = 29;
else m1 = 28;
return m1;
}
void main()
{
data input, output;
int x;
scanf("%i", &input.day);
scanf("%i", &input.month);
scanf("%i", &input.year);
scanf("%i", &x);
output = input;
int auxyear;
auxyear = input.year;
do {
x = x - leap(auxyear);
auxyear++;
output.year++;
} while (x > 366);//получили в остатке только месяцы
int auxmon;
auxmon = input.month;
do {
x = x - mon(auxmon);
auxmon++;
output.month++;
} while (x > 31); //получили только дни
output.day = x;
printf("%i %i %i ", output.day, output.month, output.year);
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.