#define _CRT_SECURE_NO_WARNINGS
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#define WEEK "日 月 火 水 木 金 土"
#define COL 24
char disp[8][80];
void strfmt(void* dest, char* fmt, int i)
{
char buf[8];
}
void calsub(int year, int month, int col)
{
struct tm tm;
struct tm* ptm;
time_t timer;
int line;
int i;
if (month < 1) {
year--;
month += 12;
}
if (12 < month) {
year++;
month -= 12;
}
strfmt(disp[0] + col * COL, "%d", year);
strfmt(disp[0] + col * COL + 8, "%d月", month);
tm.tm_year = year - 1900;
tm.tm_mon = month - 1;
tm.tm_mday = 1;
line = 2;
for (i = 1; i <= 31; i++) {
if (ptm->tm_mon != month - 1) {
break;
}
if (ptm->tm_wday == 0 && 1 < i) {
line++;
}
strfmt(disp[line] + col * COL + ptm->tm_wday * 3, "%2d", i);
timer += 24 * 60 * 60;
}
}
void cal(int year, int month)
{
int i;
for (i = 0; i < 8; i++) {
disp[i][79] = '\0';
}
calsub(year, month - 1, 0);
calsub(year, month, 1);
calsub(year, month + 1, 2);
for (i = 0; i < 8; i++) {
}
}
int main()
{
time_t timer;
struct tm* ptm;
int year;
int month;
int ch;
int flag;
year = ptm->tm_year + 1900;
month = ptm->tm_mon + 1;
while (1) {
cal(year, month);
do {
ch = _getch();
flag = 0;
switch (ch) {
case 0x1b: // ESC
return 0;
case 0x48: // up
month -= 3;
break;
case 0x49: // PageUp
year--;
break;
case 0x4b: // left
month--;
break;
case 0x4d: // right
month++;
break;
case 0x50: // down
month += 3;
break;
case 0x51: // PageDown
year++;
break;
case 0xe0:
default:
flag = 1;
}
} while (flag);
if (month < 1) {
year--;
month += 12;
}
if (12 < month) {
year++;
month -= 12;
}
}
return 0;
}
I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVkZSA8Y29uaW8uaD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCiN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