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