-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2020년 달력 만들기
54 lines (44 loc) · 986 Bytes
/
2020년 달력 만들기
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
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
int m;
char* day[7] = { "Sun", "Mon", "Tue", "Wed", "Tur", "Fri", "Sat" };
int days[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int flag = 0;
int k = 0;
printf("출력하려는 달을 입력하세요: ");
scanf("%d", &m);
switch (m) {
case 1: flag = 3; break;
case 2: flag = 6; break;
case 3: flag = 0; break;
case 4: flag = 3; break;
case 5: flag = 5; break;
case 6: flag = 1; break;
case 7: flag = 3; break;
case 8: flag = 6; break;
case 9: flag = 2; break;
case 10: flag = 4; break;
case 11: flag = 0; break;
case 12: flag = 2; break;
}
printf("\n결과: %d월\n", m);
for (int i = 0; i < 7; i++) {
printf("%s\t", day[i]);
}
printf("\n");
for(int j = 0; j < flag; j++) {
printf("\t");
k++;
}
for (int i = 1; i <= days[m-1]; i++) {
if(i < 10) printf(" %d\t", i);
else printf("%d\t", i);
k++;
if (k == 7) {
printf("\n");
k = 0;
}
}
return 0;
}