Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions 2209040028/THE test of student
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
void add_question(QuestionBank L)
{
question* p = L, * n = newQuestion();
int i;
printf("请输入问题:");
scanf("%s", n->que);
for (i = 0; i < 4; ++i)
{
printf("请输入选项%c:", i + 'A');
scanf("%s", n->options[i]);
}
while (getchar() != '\n');
printf("请输入正确选项(A、B、C、D中的一个):");
scanf("%c", &n->answer);
printf("请输入本题分数:");
scanf("%f", &n->score);
while (p->next) p = p->next;
p->next = n;
printf("录入成功\n");
}

3.2修改试题模块


void modify_question(QuestionBank L)
{
question* p = L->next;
int i = 0, choose;
while (p)
{
printf("%d. %s\n", i + 1, p->que);
p = p->next;
++i;
}
printf("%d. 返回主菜单\n", i + 1);
printf("请输入序号,选择要修改的试题:");
scanf("%d", &choose);
if (choose < 0 || choose >= i + 1)
{
if (choose != i + 1)
printf("输入错误,将返回主菜单\n");
return;
}
else
{
int j;
p = L;
for (i = 0; p->next && i < choose; ++i)
p = p->next;
printf("请输入问题:");
scanf("%s", p->que);
for (j = 0; j < 4; ++j)
{
printf("请输入选项%c:", j + 'A');
scanf("%s", p->options[j]);
}
while (getchar() != '\n');
printf("请输入正确选项(A、B、C、D中的一个):");
scanf("%c", &p->answer);
printf("请输入本题分数:");
scanf("%f", &p->score);
printf("修改成功\n");
}
}


3.3抽取试题模块


void extract_questions(QuestionBank L, QuestionBank TestPaper)
{
int N, n = 0; //N是总的抽题数,n是当前抽题数
int num = 0; //当前题目总数
printf("请输入要抽取的题目数量:");
scanf("%d", &N);
question* p = L;
while (p)
{
++num;
p = p->next;
}
if (N >= num)
{
printf("抽取题目数量大于当前已录入的题目数\n");
return;
}
printf("试题抽取中,请耐心等待.....\n");
while (n < N)
{
int i = 0, max_rand = 0;
question* p1 = L, * p2 = TestPaper;
srand(time(0) + i);
max_rand = rand() % num + 1;
while (i < max_rand)
{
p1 = p1->next;
++i;
}
if (!is_repeat(TestPaper, p1))
{
p1->nextQuestion = p2->nextQuestion;
p2->nextQuestion = p1;
++n;
}
}
printf("试卷生成成功\n");
}
界面展示:





3.4答题模块

void answer_questions(QuestionBank TestPaper)
{
question* p = TestPaper->nextQuestion;
if (!p)
printf("当前还未生成试卷\n");
while (p)
{
char ans;
print_question(p);
while (getchar() != '\n');

scanf("%c", &ans);
if (ans == p->answer)
{
p->is_right = 1;
printf("恭喜答对\n");
}
else
{
p->is_right = 0;
printf("很遗憾,答错了\n");
}
p = p->nextQuestion;
}
}

界面展示:


3.5评分模块

void give_score(QuestionBank TestPaper)
{
int r = 0, w = 0;
float score_r = 0, score_w = 0;
question* p = TestPaper->nextQuestion;
if (!p)
{
printf("请先生成试卷后答题,最后再来评分!\n");
return;
}
while (p)
{
if (p->is_right)
{
++r;
score_r += p->score;
}
else
{
++w;
score_w += p->score;
}
p = p->nextQuestion;
}
printf("本次共答了%d道题,其中答对%d道,答错%d道\n", r + w, r, w);
printf("总分:%.1f分,你的得分:%.1f分\n", score_r + score_w, score_r);
}
Loading