#include #include /* atoi */ #include /* time */ long greg2jd(int year, int month, int day); /* 月の名前。デフォルトがラテン語なのは単なる気まぐれ */ char* title[2] = { " Januarius Februarius Martius Aprilis Maius Junius", /*" January February March April May June",*/ " Quintilis Sextilis September October November December" /*" July August September October November December"*/ }; /* 日付。「一月から六月(平年版)」 「同(閏年版)」「七月から十二月」」の順 */ char* days[3][7] = { { "1 8 15 22 29 5 12 19 26 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25", "2 9 16 23 30 6 13 20 27 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26", "3 10 17 24 31 7 14 21 28 7 14 21 28 4 11 18 25 2 9 16 23 30 6 13 20 27", "4 11 18 25 1 8 15 22 1 8 15 22 29 5 12 19 26 3 10 17 24 31 7 14 21 28", "5 12 19 26 2 9 16 23 2 9 16 23 30 6 13 20 27 4 11 18 25 1 8 15 22 29", "6 13 20 27 3 10 17 24 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 23 30", "7 14 21 28 4 11 18 25 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24" }, { "1 8 15 22 29 5 12 19 26 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24", "2 9 16 23 30 6 13 20 27 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25", "3 10 17 24 31 7 14 21 28 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26", "4 11 18 25 1 8 15 22 29 7 14 21 28 4 11 18 25 2 9 16 23 30 6 13 20 27", "5 12 19 26 2 9 16 23 1 8 15 22 29 5 12 19 26 3 10 17 24 31 7 14 21 28", "6 13 20 27 3 10 17 24 2 9 16 23 30 6 13 20 27 4 11 18 25 1 8 15 22 29", "7 14 21 28 4 11 18 25 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 23 30" }, { "1 8 15 22 29 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25 2 9 16 23 30", "2 9 16 23 30 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26 3 10 17 24 31", "3 10 17 24 31 7 14 21 28 4 11 18 25 2 9 16 23 30 6 13 20 27 4 11 18 25", "4 11 18 25 1 8 15 22 29 5 12 19 26 3 10 17 24 31 7 14 21 28 5 12 19 26", "5 12 19 26 2 9 16 23 30 6 13 20 27 4 11 18 25 1 8 15 22 29 6 13 20 27", "6 13 20 27 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 23 30 7 14 21 28", "7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 1 8 15 22 29" } }; int main(int argc, char* argv[]) { int year, wday, isleap; int i; if (argc > 1) { /* 年をセット */ year = atoi(argv[1]); } else { time_t now = time(NULL); year = localtime(&now)->tm_year + 1900; } isleap = !(year % 4) && year % 100 || !(year % 400); wday = (greg2jd(year, 1, 1) + 1) % 7; /* 一月 1 日の曜日 */ /* 一月から六月までの表示開始 */ for (i=0; i