考试系统实验报告.docx
- 文档编号:24017477
- 上传时间:2023-05-23
- 格式:DOCX
- 页数:30
- 大小:20.03KB
考试系统实验报告.docx
《考试系统实验报告.docx》由会员分享,可在线阅读,更多相关《考试系统实验报告.docx(30页珍藏版)》请在冰豆网上搜索。
考试系统实验报告
#include
#include
#include
#include
#defineAdd100
intm;
typedefstructtest_q
{
chartitle[200];
charchoice_a[50];
charchoice_b[50];
charchoice_c[50];
charchoice_d[50];
charother[50];
charanswer[5];
}subject;
typedefstructhead_q
{
subject*p;
}head_q;
head_q*head=(head_q*)malloc(Max*sizeof(head_q));//需要解释............
FILE*fp,*tp;
intinitial()//初始化,把所有题目放进结构数组
{
inti=1,n=Max,flat=0;
if((fp=fopen("12.txt","r"))==NULL)
{
flat=1;
if((fp=fopen("12.txt","w"))==NULL)
{
printf("fileopenerrorone\n");
exit(0);
}
}
if(flat)
{
for(i=1;i<=10;i++)
head[i].p=(subject*)malloc(sizeof(subject));
i=1;
strcpy(head[i].p->title,"It'sseventhirty.I__gotoshooc.\n");
strcpy(head[i].p->choice_a,"A.havegot\n");
strcpy(head[i].p->choice_b,"B.havegotto\n");
strcpy(head[i].p->choice_c,"C.goto\n");
strcpy(head[i].p->choice_d,"D.hadgotto\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=2;
strcpy(head[i].p->title,"Hecameintotheclassroom_____.\n");
strcpy(head[i].p->choice_a,"A.veryupset\n");
strcpy(head[i].p->choice_b,"B.beingupset\n");
strcpy(head[i].p->choice_c,"C.toupset\n");
strcpy(head[i].p->choice_d,"D.tobeupset\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"A\n");
i=3;
strcpy(head[i].p->title,"ThisisthefirsttimethatI___atthemeeting.\n");
strcpy(head[i].p->choice_a,"A.hadspoken\n");
strcpy(head[i].p->choice_b,"B.hbavespoken\n");
strcpy(head[i].p->choice_c,"C.am\n");
strcpy(head[i].p->choice_d,"D.was\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=4;
strcpy(head[i].p->title,"Hiswholeschooleducation___only2yearsbecauseofhisillness.\n");
strcpy(head[i].p->choice_a,"A.addedup\n");
strcpy(head[i].p->choice_b,"B.addedupin\n");
strcpy(head[i].p->choice_c,"C.addedupto\n");
strcpy(head[i].p->choice_d,"D.wasaddedup\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C\n");
i=5;
strcpy(head[i].p->title,"Areyou__yourclassmateswell?
\n");
strcpy(head[i].p->choice_a,"A.gettingalong\n");
strcpy(head[i].p->choice_b,"B.getlongwith\n");
strcpy(head[i].p->choice_c,"C.gettinglongwith\n");
strcpy(head[i].p->choice_d,"D.gettingalongwithlifeinthecountry\n");
strcpy(head[i].p->other,"***********************************\n");
strcpy(head[i].p->answer,"D\n");
i=6;
strcpy(head[i].p->title,"Wearelivinga___\n");
strcpy(head[i].p->choice_a,"A.still\n");
strcpy(head[i].p->choice_b,"B.quiet\n");
strcpy(head[i].p->choice_c,"C.calm\n");
strcpy(head[i].p->choice_d,"D.silent\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=7;
strcpy(head[i].p->title,"Hisbackacheisonly____fornotwateringtheflowers.\n");
strcpy(head[i].p->choice_a,"A.areason\n");
strcpy(head[i].p->choice_b,"B.acause\n");
strcpy(head[i].p->choice_c,"C.anexcuse\n");
strcpy(head[i].p->choice_d,"D.reasons\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C\n");
i=8;
strcpy(head[i].p->title,"Ourteachersmadeus___alotofhomeworkafterachool.\n");
strcpy(head[i].p->choice_a,"A.todo\n");
strcpy(head[i].p->choice_b,"B.doing\n");
strcpy(head[i].p->choice_c,"C.do\n");
strcpy(head[i].p->choice_d,"D.tohavedoneuntilseveno'clock\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C\n");
i=9;
strcpy(head[i].p->title,"Theshop___until7o'clock.\n");
strcpy(head[i].p->choice_a,"A.staysopened\n");
strcpy(head[i].p->choice_b,"B.continuesopen\n");
strcpy(head[i].p->choice_c,"C.staysopen\n");
strcpy(head[i].p->choice_d,"D.continuesopened\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B");
i=10;
strcpy(head[i].p->title,"We______intheneighborhood.\n");
strcpy(head[i].p->choice_a,"A.happenedbeing\n");
strcpy(head[i].p->choice_b,"B.happenedbe\n");
strcpy(head[i].p->choice_c,"C.madedianies\n");
strcpy(head[i].p->choice_d,"D.keptdianies\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C");
for(i=1;i<=10;i++)
{
fputs(head[i].p->title,fp);
fputs(head[i].p->choice_a,fp);
fputs(head[i].p->choice_b,fp);
fputs(head[i].p->choice_c,fp);
fputs(head[i].p->choice_d,fp);
fputs(head[i].p->other,fp);
fputs(head[i].p->answer,fp);
}
if(fclose(fp))
{
printf("filecloseerrorone");
exit(0);
}
}
i=1;
if((flat&&(fp=fopen("12.txt","r"))==NULL))
{
printf("fileopenerrorone\n");
exit(0);
}
if(fp!
=NULL)
{
while(!
feof(fp))
{
head[i].p=(subject*)malloc(sizeof(subject));
fgets(head[i].p->title,200,fp);
fgets(head[i].p->choice_a,50,fp);
fgets(head[i].p->choice_b,50,fp);
fgets(head[i].p->choice_c,50,fp);
fgets(head[i].p->choice_d,50,fp);
fgets(head[i].p->other,50,fp);
fgets(head[i].p->answer,5,fp);
i++;
if(i>=n)
{
head=(head_q*)realloc(head,(n+Add)*sizeof(head_q));
n+=Add;
}
}
if(fclose(fp))
{
printf("filecloseerrorone");
exit(0);
}
i--;
m=i;
}
returnm;
return0;
}intwatch_all()//查看所有试题的函数
{
inti=1,j=1;
for(;i<=m;)
{
if(head[i].p==NULL)
i++;
else
{
printf("%d.%s\n%s\n%s\n",j,head[i].p->title,head[i].p->choice_a,head[i].p->choice_b);
printf("%s\n%s\n%s\n",head[i].p->choice_c,head[i].p->choice_d,head[i].p->other);
i++;
j++;
}
}
return0;
}intrestore()//功能还原函数
{
inti=1,n;
charch[50];
printf("此还原功能主要是给操作不当,导致程序运行错误,崩溃使用!
!
\n");
printf("使用此功能后,之前所有增删题目记录全部清除,\n程序还原为最初的十道英语题\n");
printf("所以此功能请谨慎使用,若确定使用此功能,请输入1\n");
scanf("%d",&n);
if(n==1)
{
for(i=1;i<=10;i++)
head[i].p=(subject*)malloc(sizeof(subject));
i=1;
strcpy(head[i].p->title,"It'sseventhirty.I__gotoshooc.\n");
strcpy(head[i].p->choice_a,"A.havegot\n");
strcpy(head[i].p->choice_b,"B.havegotto\n");
strcpy(head[i].p->choice_c,"C.goto\n");
strcpy(head[i].p->choice_d,"D.hadgotto\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=2;
strcpy(head[i].p->title,"Hecameintotheclassroom_____.\n");
strcpy(head[i].p->choice_a,"A.veryupset\n");
strcpy(head[i].p->choice_b,"B.beingupset\n");
strcpy(head[i].p->choice_c,"C.toupset\n");
strcpy(head[i].p->choice_d,"D.tobeupset\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"A\n");
i=3;
strcpy(head[i].p->title,"ThisisthefirsttimethatI___atthemeeting.\n");
strcpy(head[i].p->choice_a,"A.hadspoken\n");
strcpy(head[i].p->choice_b,"B.hbavespoken\n");
strcpy(head[i].p->choice_c,"C.am\n");
strcpy(head[i].p->choice_d,"D.was\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=4;
strcpy(head[i].p->title,"Hiswholeschooleducation___only2yearsbecauseofhisillness.\n");
strcpy(head[i].p->choice_a,"A.addedup\n");
strcpy(head[i].p->choice_b,"B.addedupin\n");
strcpy(head[i].p->choice_c,"C.addedupto\n");
strcpy(head[i].p->choice_d,"D.wasaddedup\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C\n");
i=5;
strcpy(head[i].p->title,"Areyou__yourclassmateswell?
\n");
strcpy(head[i].p->choice_a,"A.gettingalong\n");
strcpy(head[i].p->choice_b,"B.getlongwith\n");
strcpy(head[i].p->choice_c,"C.gettinglongwith\n");
strcpy(head[i].p->choice_d,"D.gettingalongwithlifeinthecountry\n");
strcpy(head[i].p->other,"***********************************\n");
strcpy(head[i].p->answer,"D\n");
i=6;
strcpy(head[i].p->title,"Wearelivinga___\n");
strcpy(head[i].p->choice_a,"A.still\n");
strcpy(head[i].p->choice_b,"B.quiet\n");
strcpy(head[i].p->choice_c,"C.calm\n");
strcpy(head[i].p->choice_d,"D.silent\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=7;
strcpy(head[i].p->title,"Hisbackacheisonly____fornotwateringtheflowers.\n");
strcpy(head[i].p->choice_a,"A.areason\n");
strcpy(head[i].p->choice_b,"B.acause\n");
strcpy(head[i].p->choice_c,"C.anexcuse");
strcpy(head[i].p->choice_d,"D.reasons\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C\n");
i=8;
strcpy(head[i].p->title,"Ourteachersmadeus___alotofhomeworkafterachool.\n");
strcpy(head[i].p->choice_a,"A.todo\n");
strcpy(head[i].p->choice_b,"B.doing\n");
strcpy(head[i].p->choice_c,"C.do\n");
strcpy(head[i].p->choice_d,"D.tohavedoneuntilseveno'clock\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C\n");
i=9;
strcpy(head[i].p->title,"Theshop___until7o'clock.\n");
strcpy(head[i].p->choice_a,"A.staysopened\n");
strcpy(head[i].p->choice_b,"B.continuesopen\n");
strcpy(head[i].p->choice_c,"C.staysopen\n");
strcpy(head[i].p->choice_d,"D.continuesopened\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"B\n");
i=10;
strcpy(head[i].p->title,"We______intheneighborhood.\n");
strcpy(head[i].p->choice_a,"A.happenedbeing\n");
strcpy(head[i].p->choice_b,"B.happenedbe\n");
strcpy(head[i].p->choice_c,"C.madedianies\n");
strcpy(head[i].p->choice_d,"D.keptdianies\n");
strcpy(head[i].p->other,"**********************************\n");
strcpy(head[i].p->answer,"C");
if
(1)
{
if((fp=fopen("12.txt","w"))==NULL)
{
printf("fileopenerrorone\n");
exit(0);
}
for(i=1;i<=10;i
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 考试 系统 实验 报告