-
Notifications
You must be signed in to change notification settings - Fork 0
/
3-b5-1.c
187 lines (185 loc) · 2.89 KB
/
3-b5-1.c
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
//2151753 彭坤宇 计科
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
printf("请输入年,月,日\n");
int year, month, day;
int z = 0;
int a, b;
scanf(" %d %d %d", &year, &month, &day);
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if (day > 31) {
printf("输入错误-日与月的非法关系\n");
a = 0;
}
else {
a = 1;
}
break;
case 2:
if (day > 29) {
printf("输入错误-日与月的非法关系\n");
a = 0;
}
else {
a = 1;
}
break;
case 4:
case 6:
case 9:
case 11:
if (day > 30) {
printf("输入错误-日与月的非法关系\n");
a = 0;
}
else {
a = 1;
}
break;
default:
printf("输入错误-日与月的非法关系\n");
a = 0;
break;
}
if (a == 1)
{
switch (month) {
case 1:
z = day;
break;
case 2:
z = 31 + day;
break;
case 3:
z = 60 + day;
break;
case 4:
z = 91 + day;
break;
case 5:
z = 121 + day;
break;
case 6:
z = 152 + day;
break;
case 7:
z = 182 + day;
break;
case 8:
z = 213 + day;
break;
case 9:
z = 243 + day;
break;
case 10:
z = 274 + day;
break;
case 11:
z = 305 + day;
break;
case 12:
z = 335 + day;
break;
}
printf("%d-%d-%d是%d年的第%d天\n", year, month, day, year, z);
}
}
else {
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if (day > 31) {
printf("输入错误-日与月的非法关系\n");
b = 0;
}
else {
b = 1;
}
break;
case 2:
if (day > 28) {
printf("输入错误-日与月的非法关系\n");
b = 0;
}
else {
b = 1;
}
break;
case 4:
case 6:
case 9:
case 11:
if (day > 30) {
printf("输入错误-日与月的非法关系\n");
b = 0;
}
else {
b = 1;
}
break;
default:
printf("输入错误-日与月的非法关系\n");
b = 0;
break;
}
if (b == 1) {
switch (month) {
case 1:
z = day;
break;
case 2:
z = 31 + day;
break;
case 3:
z = 59 + day;
break;
case 4:
z = 90 + day;
break;
case 5:
z = 120 + day;
break;
case 6:
z = 151 + day;
break;
case 7:
z = 181 + day;
break;
case 8:
z = 212 + day;
break;
case 9:
z = 243 + day;
break;
case 10:
z = 273 + day;
break;
case 11:
z = 304 + day;
break;
case 12:
z = 334 + day;
break;
}
printf("%d-%d-%d是%d年的第%d天\n", year, month, day, year, z);
}
}
return 0;
}