|
|
@ -12,28 +12,28 @@ typedef struct exam_system //
|
|
|
|
struct exam_system *next;
|
|
|
|
struct exam_system *next;
|
|
|
|
}EXAM; //类型名自定义
|
|
|
|
}EXAM; //类型名自定义
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Createlink(); //创建链表函数
|
|
|
|
|
|
|
|
void exam(); //考试初始界面函数
|
|
|
|
void management(); //题目管理函数
|
|
|
|
void management(); //题目管理函数
|
|
|
|
void add(); //添加题目函数
|
|
|
|
|
|
|
|
void show(); //遍历题库函数
|
|
|
|
|
|
|
|
void preservation(); //保存文档函数
|
|
|
|
void preservation(); //保存文档函数
|
|
|
|
void change(); //修改题目函数
|
|
|
|
void experience(); //遍历题库函数
|
|
|
|
void exam(); //考试初始界面函数
|
|
|
|
void add(); //添加题目函数
|
|
|
|
void link(); //创建链表函数
|
|
|
|
void modification(); //修改题目函数
|
|
|
|
void Answer(); //答题函数
|
|
|
|
void Answer(); //答题函数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
int sum; //题目总数
|
|
|
|
int sum; //题目总数
|
|
|
|
struct exam_system *p1,*p2,*head;
|
|
|
|
struct exam_system *p1,*p2,*head;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
link();
|
|
|
|
Createlink();
|
|
|
|
system("color 75"); //自定义background
|
|
|
|
system("color 75"); //自定义background
|
|
|
|
exam();
|
|
|
|
exam();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void link() //创建链表
|
|
|
|
void Createlink() //创建链表
|
|
|
|
{
|
|
|
|
{
|
|
|
|
head=(EXAM *)malloc(sizeof(EXAM)); //创建头节点,并给予一个动态内存
|
|
|
|
head=(EXAM *)malloc(sizeof(EXAM)); //创建头节点,并给予一个动态内存
|
|
|
|
p2=p1=head; //连续赋值
|
|
|
|
p2=p1=head; //连续赋值
|
|
|
@ -102,8 +102,8 @@ void management() //
|
|
|
|
switch(x)
|
|
|
|
switch(x)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 1:add();management();break;
|
|
|
|
case 1:add();management();break;
|
|
|
|
case 2:show();management();break;
|
|
|
|
case 2:experience();management();break;
|
|
|
|
case 3:change();management();break;
|
|
|
|
case 3:modification();management();break;
|
|
|
|
case 4:;exam();break;
|
|
|
|
case 4:;exam();break;
|
|
|
|
default :printf("输入有误!\n");break;
|
|
|
|
default :printf("输入有误!\n");break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -124,7 +124,7 @@ void preservation() //
|
|
|
|
getch();
|
|
|
|
getch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void show() //遍历题库函数
|
|
|
|
void experience() //遍历题库函数
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c,i;
|
|
|
|
int c,i;
|
|
|
|
EXAM *p=NULL;
|
|
|
|
EXAM *p=NULL;
|
|
|
@ -160,16 +160,16 @@ else
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void add() //题目添加函数
|
|
|
|
void add() //题目添加函数
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x,i;
|
|
|
|
int n,i;
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
printf("\t\t**************欢迎来到题目管理系统****************\n");
|
|
|
|
printf("\t\t**************欢迎来到题目管理系统****************\n");
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p1=(EXAM *)malloc(sizeof(EXAM));
|
|
|
|
p1=(EXAM *)malloc(sizeof(EXAM));
|
|
|
|
p2->next=p1; //相连p1、p2
|
|
|
|
p2->next=p1; //相连p1、p2
|
|
|
|
p2=p1; //指向相同
|
|
|
|
p2=p1; //指向相同
|
|
|
|
printf("请输入第%d个题目:",sum+1);
|
|
|
|
printf("请输入第%d个题目:",sum+1);
|
|
|
|
scanf("%s",p1->problem);
|
|
|
|
scanf("%s",p1->problem);
|
|
|
|
printf("请输入备选答案:\n");
|
|
|
|
printf("请输入备选答案:\n");
|
|
|
@ -183,24 +183,24 @@ void add() //
|
|
|
|
scanf("%c",&p1->right );
|
|
|
|
scanf("%c",&p1->right );
|
|
|
|
sum+=1;
|
|
|
|
sum+=1;
|
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("\t是否继续添加\n\t1.继续\n\t2.退出\n请选择:");
|
|
|
|
printf("\n继续添加下一题?\n1.是\n2.否\n你的选择是:");
|
|
|
|
scanf("%d",&x);
|
|
|
|
scanf("%d",&n);
|
|
|
|
if(x==2)
|
|
|
|
if(n==2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p2->next=NULL;
|
|
|
|
p2->next=NULL;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
}while(x==1);
|
|
|
|
}while(n==1);
|
|
|
|
preservation();
|
|
|
|
preservation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void change() //修改题目函数
|
|
|
|
void modification() //修改题目函数
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i,num;
|
|
|
|
int i,num;
|
|
|
|
EXAM *p1=NULL;
|
|
|
|
EXAM *p1=NULL;
|
|
|
|
EXAM *p2=NULL;
|
|
|
|
EXAM *p2=NULL;
|
|
|
|
show();
|
|
|
|
experience();
|
|
|
|
if(sum>=1)
|
|
|
|
if(sum>=1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p1=(EXAM *)malloc(sizeof(EXAM)); //为P1分配一个动态内存
|
|
|
|
p1=(EXAM *)malloc(sizeof(EXAM)); //为P1分配一个动态内存
|
|
|
@ -208,21 +208,19 @@ void change() //
|
|
|
|
printf("请选择修改的题目序号:");
|
|
|
|
printf("请选择修改的题目序号:");
|
|
|
|
scanf("%d",&num);
|
|
|
|
scanf("%d",&num);
|
|
|
|
for(i=0;i<num-1;i++)
|
|
|
|
for(i=0;i<num-1;i++)
|
|
|
|
{
|
|
|
|
p2=p2->next; //此时p2终于依次挪到num-1处
|
|
|
|
p2=p2->next;
|
|
|
|
|
|
|
|
} //此时p2终于依次挪到num-1处
|
|
|
|
|
|
|
|
printf("请输入题目:");
|
|
|
|
printf("请输入题目:");
|
|
|
|
scanf("%s",p1->problem);
|
|
|
|
scanf("%s",p1->problem);
|
|
|
|
printf("请输入备选答案:\n");
|
|
|
|
printf("请输入备选答案:\n");
|
|
|
|
for(i=0;i<4;)
|
|
|
|
for(i=0;i<4;)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("%c:",i+'A');
|
|
|
|
printf("%c)",i+'A');
|
|
|
|
scanf("%s",p1->answer[i++] );
|
|
|
|
scanf("%s",p1->answer[i++] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("输入正确答案:");
|
|
|
|
printf("输入正确答案:");
|
|
|
|
p1->right=getchar();
|
|
|
|
p1->right=getchar();
|
|
|
|
scanf("%c",&p1->right);
|
|
|
|
scanf("%c",&p1->right);
|
|
|
|
p1->next=p2->next->next; //此时新节点将代替原节点
|
|
|
|
p1->next=p2->next->next; //节点替换连接成功
|
|
|
|
p2->next=p1; //p1、p2连接
|
|
|
|
p2->next=p1; //p1、p2连接
|
|
|
|
p1=NULL;
|
|
|
|
p1=NULL;
|
|
|
|
p2=NULL; //最后都置为末尾
|
|
|
|
p2=NULL; //最后都置为末尾
|
|
|
@ -234,11 +232,14 @@ void Answer() //
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i,j,c;
|
|
|
|
int i,j,c;
|
|
|
|
int n;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
char write;
|
|
|
|
int score=0;
|
|
|
|
int score=0;
|
|
|
|
EXAM *p=NULL;
|
|
|
|
EXAM *p=NULL;
|
|
|
|
printf("祝你考试顺利!!\n");
|
|
|
|
printf("祝你考试顺利!!\n");
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
if(sum>0)
|
|
|
|
if(sum=0)
|
|
|
|
|
|
|
|
printf("题库中没有题目!\n");
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
i=0;
|
|
|
|
p=head;
|
|
|
|
p=head;
|
|
|
@ -251,24 +252,24 @@ void Answer() //
|
|
|
|
c=0;
|
|
|
|
c=0;
|
|
|
|
while(c<4)
|
|
|
|
while(c<4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("%c:",c+'A');
|
|
|
|
printf("%c)",c+'A');
|
|
|
|
printf("%s\n",p->answer[c++] );
|
|
|
|
printf("%s\n",p->answer[c++] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("请输入你的答案:");
|
|
|
|
printf("请输入你的答案:");
|
|
|
|
p->input=getchar();
|
|
|
|
getchar();
|
|
|
|
scanf("%c",&p->input);
|
|
|
|
scanf("%c",&write);
|
|
|
|
if(p->right==p->input)
|
|
|
|
if(p->right==write)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("\n恭喜!!你的答案是 %c ,正确答案是 %c ",p->input,p->right);
|
|
|
|
printf("\n恭喜!!你的答案是 %c ,正确答案是 %c ",write,p->right);
|
|
|
|
score+=1;
|
|
|
|
score+=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("\n太可惜了~你的答案是 %c ,正确答案是 %c ",p->input,p->right);
|
|
|
|
printf("\n太可惜了~你的答案是 %c ,正确答案是 %c ",write,p->right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i=i+1;
|
|
|
|
i=i+1;
|
|
|
|
printf("\n----------------------------------------------------------\n");
|
|
|
|
printf("\n----------------------------------------------------------\n");
|
|
|
|
if(i==n)
|
|
|
|
if(i==n) //满足用户要求
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}while(p->next!=NULL);
|
|
|
|
}while(p->next!=NULL);
|
|
|
|
printf("考试结束!\n");
|
|
|
|
printf("考试结束!\n");
|
|
|
@ -276,8 +277,6 @@ void Answer() //
|
|
|
|
getch();
|
|
|
|
getch();
|
|
|
|
;
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
printf("题库中没有题目!\n");
|
|
|
|
|
|
|
|
printf("按任意键继续!\n");
|
|
|
|
printf("按任意键继续!\n");
|
|
|
|
getchar();
|
|
|
|
getchar();
|
|
|
|
}
|
|
|
|
}
|