|
|
@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct student{
|
|
|
|
|
|
|
|
char name[25];
|
|
|
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
int t;
|
|
|
|
|
|
|
|
int f;
|
|
|
|
|
|
|
|
float total;
|
|
|
|
|
|
|
|
}STU;
|
|
|
|
|
|
|
|
typedef struct textpaper{
|
|
|
|
|
|
|
|
char title[1000];
|
|
|
|
|
|
|
|
char a[100];
|
|
|
|
|
|
|
|
char b[100];
|
|
|
|
|
|
|
|
char c[100];
|
|
|
|
|
|
|
|
char d[100];
|
|
|
|
|
|
|
|
char answer;
|
|
|
|
|
|
|
|
}Paper;
|
|
|
|
|
|
|
|
void Openfile();//打开文件
|
|
|
|
|
|
|
|
float pinfen(char,char);//评分
|
|
|
|
|
|
|
|
void chengji(); //按照成绩梯度输出成绩
|
|
|
|
|
|
|
|
void design();//出题系统
|
|
|
|
|
|
|
|
void check();//查看题库
|
|
|
|
|
|
|
|
void del();//删除题目
|
|
|
|
|
|
|
|
void alter();//修改题目
|
|
|
|
|
|
|
|
int a=0,d=0,t=0;//a表示人数 t初始化题目个数 <-全局变量
|
|
|
|
|
|
|
|
struct student stu[100];
|
|
|
|
|
|
|
|
Paper problem[1000];
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
|
|
|
|
char ch,ch1,key;//key表示学生输入的答案
|
|
|
|
|
|
|
|
float sum=0,count=0;
|
|
|
|
|
|
|
|
int b,c;
|
|
|
|
|
|
|
|
Openfile();//打开题库
|
|
|
|
|
|
|
|
printf("================================================================================\n\n");
|
|
|
|
|
|
|
|
printf("================================================================================\n\n");
|
|
|
|
|
|
|
|
printf("*************************欢迎使用考试系统*******************************\n\n");
|
|
|
|
|
|
|
|
printf("--------------------------------------------------------------------------------\n\n");
|
|
|
|
|
|
|
|
printf("********************************************************************************\n\n");
|
|
|
|
|
|
|
|
printf("================================================================================\n\n");
|
|
|
|
|
|
|
|
printf("请按任意键进入考试系统系统:\n");
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("是否进入考试: y/n y为是;n为不是\n");
|
|
|
|
|
|
|
|
scanf("%c",&ch1);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
if(ch1=='y'||ch1=='Y'){
|
|
|
|
|
|
|
|
printf("--------------------------先录入学生信息-----------------------------\n");
|
|
|
|
|
|
|
|
printf("--------------------是否选择录入多人 Y/N --------\n");
|
|
|
|
|
|
|
|
printf("--------------------请输入-------\n");
|
|
|
|
|
|
|
|
scanf("%c",&ch);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ch=='y'||ch=='Y'){
|
|
|
|
|
|
|
|
printf("请输入您需要录入的人数\n");
|
|
|
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
|
|
|
for(int i=0;i<a;i++){
|
|
|
|
|
|
|
|
printf("请输入第%d位学生的信息\n",i+1);
|
|
|
|
|
|
|
|
scanf("%s %d",stu[i].name,&stu[i].num);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
a=1;
|
|
|
|
|
|
|
|
printf("单名考生请输入考生信息:\n");
|
|
|
|
|
|
|
|
scanf("%s %d",stu[0].name,&stu[0].num);//
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("准备进入考试了!!你准备好了吗!!\n");
|
|
|
|
|
|
|
|
printf("请输入Y进入考试 \n");
|
|
|
|
|
|
|
|
scanf("%c",&ch);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ch=='y'||ch=='Y'){
|
|
|
|
|
|
|
|
printf("请注意,所有答案均需要填大写。否则,系统将认为您的答案错误!\n");
|
|
|
|
|
|
|
|
printf("本次考试一共有%d道题\n",t);
|
|
|
|
|
|
|
|
printf("请考生耐心作答,争取优异成绩!\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int j=0;j<a;j++){
|
|
|
|
|
|
|
|
sum=0;
|
|
|
|
|
|
|
|
for(int i=0;i<t;i++){
|
|
|
|
|
|
|
|
printf("第%d题\n",i+1);
|
|
|
|
|
|
|
|
printf("题目:\n");
|
|
|
|
|
|
|
|
printf("%s\n",problem[i].title);
|
|
|
|
|
|
|
|
printf("A:%s\n",problem[i].a);
|
|
|
|
|
|
|
|
printf("B:%s\n",problem[i].b);
|
|
|
|
|
|
|
|
printf("C:%s\n",problem[i].c);
|
|
|
|
|
|
|
|
printf("D:%s\n",problem[i].d);
|
|
|
|
|
|
|
|
printf("请输入您的答案:");
|
|
|
|
|
|
|
|
key=getchar();
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
count=pinfen(key,problem[i].answer);//在答题的过程中评定分数
|
|
|
|
|
|
|
|
sum+=count;
|
|
|
|
|
|
|
|
system("cls");//清屏
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stu[j].total=sum;
|
|
|
|
|
|
|
|
printf("名字:%s\n",stu[j].name);
|
|
|
|
|
|
|
|
printf("总分:%.2f\n",stu[j].total);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
chengji();//输出学生成绩
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
while(1){//
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf(" *************************菜单****************************\n");
|
|
|
|
|
|
|
|
printf(" * 1. 我要出题 2. 查看题库 *\n");
|
|
|
|
|
|
|
|
printf(" * 3. 删除题目 4. 修改题目 *\n");
|
|
|
|
|
|
|
|
printf(" *********************************************************\n");
|
|
|
|
|
|
|
|
z: printf("请输入你要选择的功能:\n");
|
|
|
|
|
|
|
|
scanf("%d",&c);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
switch(c){
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
design();//出题系统
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
check();//查看题库
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
del();//删除题目
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
alter();//修改题目
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
printf("您输入的序号有误,请重新输入:(\n");
|
|
|
|
|
|
|
|
goto z; //拓展了goto语句的使用 头文件stdio
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Openfile(){ //打开文件
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
|
|
|
|
FILE *fp1;
|
|
|
|
|
|
|
|
fp1= fopen("考试题库data2.txt","ab+");//以追加的形式打开文本文件(若不存在,则新建;反之,在原文件后追加)并且在文件尾部追加数据之后,可以由位置函数设置开始读的起始位置
|
|
|
|
|
|
|
|
if(fp1==NULL){
|
|
|
|
|
|
|
|
printf("很抱歉无法打开数据文件:( \n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp1)){//feof 表示文件是否结束
|
|
|
|
|
|
|
|
if( fread(&problem[t],sizeof(Paper),1,fp1)==1){//fread 读取数据
|
|
|
|
|
|
|
|
t++;//读取题目的题数
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp1);//很重要的,不能漏掉
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void design(){//出题系统
|
|
|
|
|
|
|
|
printf("请输入题目:\n");
|
|
|
|
|
|
|
|
gets(problem[t].title);
|
|
|
|
|
|
|
|
printf("请输入A选项:\n");
|
|
|
|
|
|
|
|
gets(problem[t].a);
|
|
|
|
|
|
|
|
printf("请输入B选项:\n");
|
|
|
|
|
|
|
|
gets(problem[t].b);
|
|
|
|
|
|
|
|
printf("请输入C选项:\n");
|
|
|
|
|
|
|
|
gets(problem[t].c);
|
|
|
|
|
|
|
|
printf("请输入D选项:\n");
|
|
|
|
|
|
|
|
gets(problem[t].d);
|
|
|
|
|
|
|
|
printf("请输入正确选项:\n");
|
|
|
|
|
|
|
|
problem[t].answer=getchar();
|
|
|
|
|
|
|
|
t++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void check(){//查看题库
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("本题库共有%d道题目\n",t);
|
|
|
|
|
|
|
|
for(i=0;i<t;i++){
|
|
|
|
|
|
|
|
printf("第%d题:\n",i+1);
|
|
|
|
|
|
|
|
printf("题目:\n");
|
|
|
|
|
|
|
|
printf("%s\n", problem[i].title);
|
|
|
|
|
|
|
|
printf(" A:%s\n", problem[i].a);
|
|
|
|
|
|
|
|
printf(" B:%s\n", problem[i].b);
|
|
|
|
|
|
|
|
printf(" C:%s\n", problem[i].c);
|
|
|
|
|
|
|
|
printf(" D:%s\n", problem[i].d);
|
|
|
|
|
|
|
|
printf("正确答案为:%c\n", problem[i].answer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
putchar('\n');
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void del(){//删除题目
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
char chi;
|
|
|
|
|
|
|
|
printf("请输入您要删除的题目的标号:\n");
|
|
|
|
|
|
|
|
scanf("%d",&i);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
i=i-1;
|
|
|
|
|
|
|
|
printf("您要删除的题目内容如下:\n");
|
|
|
|
|
|
|
|
printf("第%d题\n",i+1);
|
|
|
|
|
|
|
|
printf("题目:\n");
|
|
|
|
|
|
|
|
printf("%s\n", problem[i].title);
|
|
|
|
|
|
|
|
printf(" A:%s\n", problem[i].a);
|
|
|
|
|
|
|
|
printf(" B:%s\n", problem[i].b);
|
|
|
|
|
|
|
|
printf(" C:%s\n", problem[i].c);
|
|
|
|
|
|
|
|
printf(" D:%s\n", problem[i].d);
|
|
|
|
|
|
|
|
printf("正确答案为:%c\n", problem[i].answer);
|
|
|
|
|
|
|
|
printf("\n您确定删除该题目吗? Y/N\n");
|
|
|
|
|
|
|
|
chi = getchar();
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
if(chi=='N'||chi=='n'){
|
|
|
|
|
|
|
|
printf("即将返回上一级:(\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(;i<t;i++){
|
|
|
|
|
|
|
|
problem[i]=problem[i+1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t--;
|
|
|
|
|
|
|
|
printf("删除成功,所有题目编号已经更新 :)\n\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void alter(){//修改题目
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
char chi;
|
|
|
|
|
|
|
|
printf("\n请输入你要修改的题目的编号: ");
|
|
|
|
|
|
|
|
scanf("%d", &i);
|
|
|
|
|
|
|
|
i = i - 1;
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
printf("\n您要修改的题目内容如下: \n");
|
|
|
|
|
|
|
|
printf("\nNo.%d\n", i + 1);
|
|
|
|
|
|
|
|
printf("Title:\n");
|
|
|
|
|
|
|
|
printf("%s\n", problem[i].title);
|
|
|
|
|
|
|
|
printf(" A:%s\n", problem[i].a);
|
|
|
|
|
|
|
|
printf(" B:%s\n", problem[i].b);
|
|
|
|
|
|
|
|
printf(" C:%s\n", problem[i].c);
|
|
|
|
|
|
|
|
printf(" D:%s\n", problem[i].d);
|
|
|
|
|
|
|
|
printf("正确答案为:%c\n", problem[i].answer);
|
|
|
|
|
|
|
|
printf("\n您确定修改该题目吗? Y/N\n");
|
|
|
|
|
|
|
|
chi = getchar();
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
if(chi == 'N' || chi == 'n')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("即将返回到菜单页面 :)\n\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("请输入题目:\n");
|
|
|
|
|
|
|
|
gets(problem[i].title);
|
|
|
|
|
|
|
|
printf("请输入A选项:\n");
|
|
|
|
|
|
|
|
gets(problem[i].a);
|
|
|
|
|
|
|
|
printf("请输入B选项:\n");
|
|
|
|
|
|
|
|
gets(problem[i].b);
|
|
|
|
|
|
|
|
printf("请输入C选项:\n");
|
|
|
|
|
|
|
|
gets(problem[i].c);
|
|
|
|
|
|
|
|
printf("请输入D选项:\n");
|
|
|
|
|
|
|
|
gets(problem[i].d);
|
|
|
|
|
|
|
|
printf("请输入正确选项:\n");
|
|
|
|
|
|
|
|
problem[i].answer = getchar();
|
|
|
|
|
|
|
|
printf("修改成功,即将返回上一级 :)\n\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
float pinfen(char key,char ch){
|
|
|
|
|
|
|
|
if(key==ch){
|
|
|
|
|
|
|
|
return 10.0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void chengji(){//冒泡排序法
|
|
|
|
|
|
|
|
STU temp;
|
|
|
|
|
|
|
|
float sum=0;
|
|
|
|
|
|
|
|
printf("*姓名 学号 成绩\n");
|
|
|
|
|
|
|
|
for(int i=0;i<a;i++){
|
|
|
|
|
|
|
|
for(int j=i+1;j<a;j++){
|
|
|
|
|
|
|
|
if(stu[i].total<stu[j].total){
|
|
|
|
|
|
|
|
temp=stu[j];
|
|
|
|
|
|
|
|
stu[j]=stu[i];
|
|
|
|
|
|
|
|
stu[i]=temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0;i<a;i++){
|
|
|
|
|
|
|
|
printf("%s %03d %.2f \n ",stu[i].name,stu[i].num,stu[i].total);
|
|
|
|
|
|
|
|
sum+=stu[i].total;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("****平均分为%.2f\n",sum/a);
|
|
|
|
|
|
|
|
}
|