1、#include #include #include #include#includestruct testchar ask500;/选择题题目char answer1100; char answer2100; char answer3100; char answer4100;char da100; int title100;/随机抽题char right10; m1000; void menu()printf( *单项选择题标准化考试系统*n);printf( *n);printf( 1.试题录入 *n);printf( 2.查看全部试题 *n);printf( 3.试题抽取并答题 *n);
2、printf( 4.判卷并打分 *n);printf( 5.退出系统 *n);printf( *n);int input(int cnt)int i,count,choice=0; printf(开始输入统计.n);count=cnt; for(i=cnt;i1000;i+)printf(Continue?(1 Yes 0 No):);scanf(%d,&choice);getchar();if(choice=0)break;elseif(choice=1) printf(请输入第%d道题题目,题干和选项:n,i+1); printf(请输入题目:); gets(mi.ask); printf
3、(请输入选项A:); gets(mi.answer1); printf(请输入选项B:); gets(mi.answer2); printf(请输入选项C:); gets(mi.answer3); printf(请输入选项D:); gets(mi.answer4); printf(请输入答案:); scanf(%c,&mi.right); cnt+; if(count!=cnt) printf(n题目输入成功:); else printf(n未输入统计!);return cnt;void list(int cnt)int i;printf(开始显示全部题目.); printf(n目前文件夹中全
4、部统计显示以下:nn);for(i=0;icnt)printf(您抽取题目超出了题目总数); else for(i=1;i=n;i+) here:x=rand()%n; titlei=x; for(j=0;ji;j+) if(titlei=titlej) goto here; printf( =n);printf(输出抽取到第%d题目,i);printf(:%sn,mx.ask); printf(A:%sn,mx.answer1); printf(B:%sn,mx.answer2); printf(C:%sn,mx.answer3); printf(D:%sn,mx.answer4); pri
5、ntf(请输入你答案:); scanf(%s,mx.da); printf( =n); printf(答题成功,按任意键返回主菜单.); void ask(int cnt)int i,n;int count=0;printf(请输入已经答题数目:);scanf(%d,&n);for(i=0;icnt;i+) if(!strcmp(mi.da,mi.right) count+; printf(你答正确总题数是%dn,count); printf(你最终得分为%d,(100/n)*count); system(pause);int main()FILE * fp;int i=0,count=0,s
6、elect;fp=fopen(tiku.txt,a+);if(fp=NULL)printf(File open error!n);exit(0);while(!feof(fp)if(fread(&mi,sizeof(struct test),1,fp)=1)i+;count+;fclose(fp);while(1)printf(目前文件夹总共有%d条统计.n,count);menu();printf(请输入你选择:);scanf(%d,&select);switch(select)case 1:count=input(count);break;case 2:list(count);break;case 3:rande(count);break; case 4:ask(count);break;case 5:fp=fopen(tiku.txt,w);printf(开始保留文件,按任意键继续.);getchar();getchar();for(i=0;icount;i+)fwrite(&mi,sizeof(struct test),1,fp);fclose(fp);printf(n文件保留成功,按任意键退出系统.);getchar();exit(0);default:printf(输入错误,请重新输入.);