Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Long-year/C/long-year.c
Normal file
28
Task/Long-year/C/long-year.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
// https://webspace.science.uu.nl/~gent0113/calendar/isocalendar.htm
|
||||
|
||||
int p(int year) {
|
||||
return (int)((double)year + floor(year/4) - floor(year/100) + floor(year/400)) % 7;
|
||||
}
|
||||
|
||||
int is_long_year(int year) {
|
||||
return p(year) == 4 || p(year - 1) == 3;
|
||||
}
|
||||
|
||||
void print_long_years(int from, int to) {
|
||||
for (int year = from; year <= to; ++year) {
|
||||
if (is_long_year(year)) {
|
||||
printf("%d ", year);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
printf("Long (53 week) years between 1800 and 2100\n\n");
|
||||
print_long_years(1800, 2100);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue