1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
#define _CRT_SECURE_NO_DEPRECATE #pragma warning(disable:4996) #pragma comment(lib,"libssl.lib") #pragma comment(lib,"libcrypto.lib")
#include <stdio.h> #include <string.h> #include <openssl/md5.h>
int spaces(int year) { int week = 6; int flag = 0;
for (int i = 1949; i < year; i++) { if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { if (week > 7) { week -= 7; } else { week++; }
flag = 1; } else { if (flag == 1) { week += 2; flag = 0; } else { week++; }
if (week > 7) { week -= 7; } } } return week; }
int month_days(int year,int month) { int n = 0; switch (month) { case 1: n = 31; break; case 2: if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { n = 29; } else { n = 28; } break; case 3: n = 31; break; case 4: n = 30; break; case 5: n = 31; break; case 6: n = 30; break; case 7: n = 31; break; case 8: n = 31; break; case 9: n = 30; break; case 10: n = 31; break; case 11: n = 30; break; case 12: n = 31; break; }
return n; }
void month_week(int year, int start_week, int month, int n, int n1) { int week = 0;
if (month == 1) { week = start_week; } else { week = start_week + (n1 % 7); if (week > 7) { week = week - 7; } }
for (int m = 1; m < week; m++) { printf(" "); }
for (int i = 0; i < n; i++) { if ((week + i) % 7 == 1) { printf("\n"); } if (i < 10) { printf(" %2d",i+1); } else { printf(" %2d",i+1); } }
}
void printf_year(int start) { int days = 0; char strings[12][4] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; printf("\n------------%d------------\n",start); printf(" 一 二 三 四 五 六 日\n"); printf("----------------------------");
for (int i = 1; i <= 12; i++) { days += month_days(start, i-1); printf("\n\n\t %s \t\n",strings[i-1]); month_week(start, spaces(start), i, month_days(start, i), days); } }
int main(void) { int start = 0; int end = 0;
printf("请输入开始年份:"); scanf("%d", &start);
printf("请输入结束年份:"); scanf("%d", &end); for (int i = 0; i <= end - start; i++) { printf_year(start+i); printf("\n"); } return 0; }
|