-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcode.sin
436 lines (436 loc) · 13.5 KB
/
code.sin
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#include<stdio.h>
#include<Math.h>
#include<string.h>
#include <time.h>
#include <Windows.h>
struct danxuanti //单选题
{
char timu[80000];
char answer[100];
}*p, dx[100];
struct duoxuanti //多选题
{
char timu[80000];
char answer[100];
}*p1, dx1[100];
struct panduanti //判断题
{
char timu[80000];
char answer[100];
}*p2, dx2[100];
struct count //题目数量
{
int n1;
int n2;
int n3;
}c;
struct duoxuantidaan //多选题 答案
{
char answer[100];
}dx3[100];
struct kaoshitime //多选题 答案
{
int hour;
int min;
}t;
struct score //考试得分
{
int score1;
int score2;
int score3;
int total;
}s;
int choose;//题目类型
int people = 0;//考试人数
char answer1[100] = { ' ' };//存放答案的数组
char answer2[100] = { ' ' };//存放答案的数组
int scoreall[80];
/*函数声明*/
void danxuan();
void danxuan() {
printf("请输入录入题目的数量:");
scanf("%d", &c.n1);
int i;
//printf("(输入回车以确定,输入空格代替换行!)\n");
for (i = 0; i < c.n1; i++) {
printf("请输入第%d道题的题目\n", i + 1);
getchar();
gets(dx[i].timu);
printf("请输入第%d道题的答案\n", i + 1);
gets(dx[i].answer);
}
printf("输入完毕,即将返回主菜单!\n");
system("pause");
system("cls"); //清屏
}
void duoxuan();
void duoxuan() { /*多选*/
printf("请输入录入题目的数量:");
scanf("%d", &c.n2);
int i;
printf("(输入回车以确定)");
for (i = 0; i < c.n2; i++) {
printf("请输入第%d道题的题目\n", i + 1);
getchar();
gets(dx1[i].timu);
printf("请输入第%d道题的答案\n", i + 1);
gets(dx1[i].answer);
}
printf("输入完毕,即将返回主菜单!\n");
system("pause");
system("cls"); //清屏
}
void read(int n);
void read(int n) {
/*单选题*/
if (c.n1 != -1) {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t\t\t单选题题目和答案如下:\n");
printf("\t\t\t\t**************************************************\n");
int count = 0;
for (p = dx; p < dx + c.n1; p++) {
printf("第%d题题目为:\n %s\n", count + 1, p->timu);
printf("第%d题答案为:\n %s\n", count + 1, p->answer);
count++;
}
}
/*多选题*/
if (c.n2 != -1) {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t\t\t多选题题目和答案如下:\n");
printf("\t\t\t\t**************************************************\n");
int count1 = 0;
for (p1 = dx1; p1 < dx1 + c.n2; p1++) {
printf("第%d题题目为:\n %s\n", count1 + 1, p1->timu);
printf("第%d题答案为:\n %s\n", count1 + 1, p1->answer);
count1++;
}
}
/*判断题*/
if (c.n3 != -1) {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t\t\t判断题题目和答案如下:\n");
printf("\t\t\t\t**************************************************\n");
int count1 = 0;
for (p2 = dx2; p2 < dx2 + c.n3; p2++) {
printf("第%d题题目为:\n %s\n", count1 + 1, p2->timu);
printf("第%d题答案为:\n %s\n", count1 + 1, p2->answer);
count1++;
}
}
if (choose < 1 && choose>3) {
printf("暂无数据\n");
}
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t\t\t即将返回主菜单!\n");
printf("\t\t\t\t**************************************************\n");
system("pause");
system("cls"); //清屏
}
void settime();
void settime() {
int hour;
int min;
printf("请输入考试结束的时间:\n");
printf("小时(例:17):\n");
scanf("%02d", &t.hour);
printf("分钟(例:15):\n");
scanf("%02d", &t.min);
printf("hour=%02d min=%02d\n",t. hour, t.min);
system("pause");
}
void menu();
void menu() {
time_t timep; //系统时间
struct tm* p;
time(&timep);
p = gmtime(&timep);
printf("\t\t\t\t\t\t %d年%02d月%02d日\n", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday);
printf("\t\t\t\t\t\t 当前时间%02d时%02d分%\n", 8 + p->tm_hour, p->tm_min);
printf("\t\t\t\t\t**************************************\n");
printf("\t\t\t\t\t**************************************\n");
printf("\t\t\t\t\t****** ********\n");
printf("\t\t\t\t\t****** 考 试 系 统 ********\n");
printf("\t\t\t\t\t****** ********\n");
printf("\t\t\t\t\t****** ********\n");
printf("\t\t\t\t\t****** 1. 录入题目信息 ********\n");
printf("\t\t\t\t\t****** 2. 查看试卷信息 ********\n");
printf("\t\t\t\t\t****** 3. 考试时间设置 ********\n");
printf("\t\t\t\t\t****** 4. 考 试 分 析 ********\n");
printf("\t\t\t\t\t****** 5. 删 除 题 目 ********\n");
printf("\t\t\t\t\t****** 6. 开 始 考 试 ********\n");
printf("\t\t\t\t\t****** 0. 退 出 系 统 ********\n");
printf("\t\t\t\t\t****** ********\n");
printf("\t\t\t\t\t****** ********\n");
printf("\t\t\t\t\t**************************************\n");
printf("\t\t\t\t\t**************************************\n");
}
void panduan();
void panduan() {
printf("请输入录入题目的数量:");
scanf("%d", &c.n3);
int i;
printf("(输入回车以确定)");
for (i = 0; i < c.n3; i++) {
printf("请输入第%d道题的题目\n", i + 1);
getchar();
gets(dx2[i].timu);
printf("请输入第%d道题的答案(请输入T或F)\n", i + 1);
gets(dx2[i].answer);
}
printf("输入完毕,即将返回主菜单!\n");
system("pause");
system("cls"); //清屏
}
void delete1();
void delete1() {
int num;//要删除的题号
int i;
int leixing;
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** 请选择要输入题目的类型 ****\n");
printf("\t\t\t\t**** 1.单选题 ****\n");
printf("\t\t\t\t**** 2.多选题 ****\n");
printf("\t\t\t\t**** 3.判断题 ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**************************************************\n");
printf("请选择要输入题目的类型:\n");
scanf("%d", &leixing);
while (leixing != 1 && leixing != 2) {
printf("您的输入有错,请重新选择\n");
scanf("%d", &leixing);
}
if (leixing == 1) {
printf("单选题共有%d题:\n", c.n1);
if (c.n1 != 0) {
printf("请输入要删除的题目题号:\n");
scanf("%d", &num);
for (i = num; i < c.n1; i++)//删除题目
{
dx[i - 1] = dx[i];
c.n1--;
printf("删除成功!\n");
}
}
else {
printf("暂无题目!\n");
}
}
else if (leixing == 2) {
printf("多选题共有%d题:\n", c.n2);
if (c.n2 != 0) {
printf("请输入要删除的题目题号:\n");
scanf("%d", &num);
for (i = num; i < c.n2; i++)//删除题目
{
dx1[i - 1] = dx1[i];
c.n2--;
printf("删除成功!\n");
}
}
else {
printf("暂无题目!\n");
}
}
system("pause");
system("cls"); //清屏
}
void analysis();
void analysis() {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** 考 试 分 析 ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**************************************************\n");
int i;
int max = -999;
int min = 999;
for (i = 0; i < people; i++) {
printf("第%d个考生总分为:%d\n", i+1,scoreall[i]);
}
for (i = 0; i < people; i++) {
if (scoreall[i] > max) { //判断上面定义的max数组第二位是否大于第一位
max = scoreall[i]; //如果大于max,max变为数组的第二位,依次判断,求出最大值
}
}
for (i = 0; i < people; i++) {
if (scoreall[i] < min) { //判断上面定义的max数组第二位是否大于第一位
min = scoreall[i]; //如果大于max,max变为数组的第二位,依次判断,求出最大值
}
}
float sum = 0;
float aver = 0;
for (i = 0; i < people; i++) {
sum = scoreall[i] + sum;
}
aver = sum / (float)people;
if (max != -999) printf("考试最高分为:%d\n", max);
if (min != 999)printf("考试最低分为:%d\n", min);
if (sum != 0)printf("考试平均分为:%.2f\n",aver);
system("pause");
system("cls"); //清屏
}
int menu2(int n);
int menu2(int n) {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** 请选择要输入题目的数量和类型 ****\n");
printf("\t\t\t\t**** 1.单选题 ****\n");
printf("\t\t\t\t**** 2.多选题 ****\n");
printf("\t\t\t\t**** 3.判断题 ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**** ****\n");
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t**************************************************\n");
printf("请输入录入题目的类型:");
scanf("%d", &choose);
while (choose > 3 || choose < 1) {//当输入不合理重新输入
printf("您的输入有错,请重新选择\n");
scanf("%d", &choose);
}
switch (choose) {
case 1:
{
danxuan();
}break;
case 2:duoxuan(); break;
case 3:panduan(); break;
}
return n;
}
void start();
void start() {
char name[80];
int xuehao;
int cxuehao = { 123 };
printf("请输入学号:\n");
scanf("%d", &xuehao);
printf("请输入姓名:\n");
scanf("%s", name);
if (xuehao == cxuehao) {
printf("考试开始!\n");
time_t timep; //系统时间
struct tm* q;
time(&timep);
q = gmtime(&timep);
printf("\t\t\t\t 考试时间%02d时%02d分%02d秒%\n", 8 + q->tm_hour, q->tm_min,q->tm_sec);
/*单选题*/
if (c.n1 != -1) {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t\t\t单选题测试:\n");
printf("\t\t\t\t**************************************************\n");
int count1 = 0;
for (p = dx; p < dx + c.n1; p++) {
printf("第%d题题目为:\n %s\n", count1 + 1, p->timu);
printf("请输入答案:\n ");
getchar();
answer1[count1] = getchar();
count1++;
}
}
if (c.n3 != -1) {
printf("\t\t\t\t**************************************************\n");
printf("\t\t\t\t\t\t判断题测试:\n");
printf("\t\t\t\t**************************************************\n");
int count1 = 0;
for (p2 = dx2; p2 < dx2 + c.n3; p2++) {
printf("第%d题题目为:\n %s\n", count1 + 1, p2->timu);
printf("请输入答案(T或F):\n ");
getchar();
answer2[count1] = getchar();
count1++;
}
}
int i = 0;
s.score1 = 0;
for (i = 0; i < c.n1; i++) {//计算单选题得分
int flag = 0;
if (answer1[i] == dx[i].answer[0]) {
s.score1 += 2;
flag = 1;
printf("单选题第%d题的得分为:2\n",i+1);
}
if(flag==0)printf("单选题第%d题的得分为:0\n",i+1);
}
for (i = 0; i < c.n3; i++) {//计算判断题得分
int flag1 = 0;
if (answer2[i] == dx2[i].answer[0]) {
s.score3 += 2;
flag1 = 1;
printf("判断题第%d题的得分为:2\n",i+1);
}
if(flag1==0)printf("判断题第%d题的得分为:0\n",i+1);
}
printf("考试已结束!\n");
if(c.n1!=-1)printf("考试单选题得分为:%d\n", s.score1);
if (c.n3 != -1)printf("考试判断题得分为:%d\n", s.score3);
printf("考试总分为:%d\n", s.score3+s.score1);
scoreall[people] = s.score3 + s.score1;
people++;
time_t timep1; //系统时间
struct tm* q1;
time(&timep1);
q1 = gmtime(&timep1);
printf("\t\t\t\t 考试结束,时间为%02d时%02d分%02d秒%\n", 8 + q1->tm_hour, q1->tm_min, q1->tm_sec);
printf("\n");
system("pause");
system("cls"); //清屏
}
else {
printf("无此考生\n");
}
}
void settime();
int main(void) {
system("color 17");//设置背景颜色
int a;
int n = -1;//题目数量
L1: menu();//打印第一个菜单
int choose;
printf("请输入数字选择系统功能:");
scanf("%d", &choose);
while (choose > 6 || choose < 0) {//当输入不合理重新输入
printf("您的输入有错,请重新选择\n");
scanf("%d", &choose);
}
system("color 07");//设置背景颜色
system("cls"); //清屏
switch (choose) {
case 1: {
n = menu2(n);//录入题目
}break;
case 2: {
read(n);//查看题目
} break;
case 3: {
settime();//设置考试时间
} break;
case 4: {
analysis();//成绩分析
} break;
case 5: {
delete1();//删除题目
} break;
case 6: {
start();//开始考试
} break;
case 0:
{
printf("您选择退出系统!\n");
return 0;
}
}
goto L1;
printf("main函数运行结束\n");
}