You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tanrunti_001/课程设计(final)(final).cpp

285 lines
7.5 KiB

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
6 years ago
typedef struct exam_system //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
char problem[150];
char answer[4][20];
char right;
char input;
struct exam_system *next;
}EXAM; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>
6 years ago
void Createlink(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void exam(); //<2F><><EFBFBD>Գ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><E6BAAF>
void management(); //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void preservation(); //<2F><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
6 years ago
void experience(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2BAAF>
void add(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
void modification(); //<2F>޸<EFBFBD><DEB8><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
void Answer(); //<2F><><EFBFBD><EFBFBD><E2BAAF>
6 years ago
FILE *fp;
int sum; //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
struct exam_system *p1,*p2,*head;
int main()
{
6 years ago
Createlink();
system("color 75"); //<2F>Զ<EFBFBD><D4B6><EFBFBD>background
exam();
return 0;
}
6 years ago
void Createlink() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
head=(EXAM *)malloc(sizeof(EXAM)); //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ڵ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>̬<EFBFBD>ڴ<EFBFBD>
p2=p1=head; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
p1->next=NULL; //<2F><>p1ָ<31><D6B8>ĩβ
if((fp=fopen("D:\\exam.txt","r+"))==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>");
exit(0);
}
while(1)
{
p1=(EXAM*)malloc(sizeof(EXAM));
if(fread(p1,sizeof(EXAM),1,fp)==0) //<2F><>ȡ<EFBFBD><C8A1>Ϣ
break; //<2F><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
p2->next=p1; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>
p2=p1; //p1<70><31>p2ͬʱָ<CAB1><D6B8><EFBFBD>¿<EFBFBD><C2BF>ٵĽڵ<C4BD>
sum++;
p2->next=NULL; //<2F><>p2ָ<32><D6B8>ĩβ
}
fclose(fp);
}
void exam() //<2F><><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><E6BAAF>
{
int x;
system("cls");
printf("\t\t*********<2A><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><E2BFBC>ϵͳ*********\n");
printf("\t\t* *\n");
printf("\t\t* 1.<2E><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD> *\n");
printf("\t\t* *\n");
printf("\t\t* 2.<2E><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> *\n");
printf("\t\t* *\n");
printf("\t\t* 3.<2E>˳<EFBFBD> *\n");
printf("\t\t* *\n");
printf("\t\t********************************************\n");
printf("\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&x);
switch(x)
{
case 1:management();break;
case 2:Answer();break;
case 3:exit(0);break;
default :printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");break;
}
}
void management() //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int x;
system("cls");
printf("\t\t************<2A><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ϵͳ************\n");
printf("\t\t* *\n");
printf("\t\t* 1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ *\n");
printf("\t\t* *\n");
printf("\t\t* 2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *\n");
printf("\t\t* *\n");
printf("\t\t* 3.<2E>޸<EFBFBD><DEB8><EFBFBD>Ŀ *\n");
printf("\t\t* *\n");
printf("\t\t* 4.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> *\n");
printf("\t\t* *\n");
printf("\t\t********************************************\n");
printf("\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&x);
switch(x)
{
case 1:add();management();break;
6 years ago
case 2:experience();management();break;
case 3:modification();management();break;
case 4:;exam();break;
default :printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");break;
}
}
void preservation() //<2F><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
{
EXAM *current=NULL;
current=head->next;
fp=fopen("D:\\exam.txt","w+");
do
{
fwrite(current,sizeof(EXAM),1,fp); //<2F><><EFBFBD><EFBFBD><EFBFBD>
current=current->next; //<2F><>ǰָ<C7B0><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
}while(current!=NULL); //ֱ<><D6B1>ָ<EFBFBD><D6B8>ĩβ
fclose(fp);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
getch();
}
6 years ago
void experience() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2BAAF>
{
int c,i;
EXAM *p=NULL;
system("cls");
if(sum==0)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
getch();
}
else
{
p=head;
i=0;
do
{
p=p->next;
printf("%d.%s\n",i+1,p->problem);
c=0;
while(c<4)
{
printf("%c:",c+'A');
printf("%s\n",p->answer[c++] );
}
printf("<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
printf("%c\n",p->right);
i=i+1;
printf("\n-------------------------------------------------------------\n");
}while(p->next!=NULL);
p=NULL;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
getch();
}
}
6 years ago
void add() //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD>
{
6 years ago
int n,i;
system("cls");
printf("\t\t**************<2A><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ϵͳ****************\n");
do
{
p1=(EXAM *)malloc(sizeof(EXAM));
6 years ago
p2->next=p1; //<2F><><EFBFBD><EFBFBD>p1<70><31>p2
p2=p1; //ָ<><D6B8><EFBFBD><EFBFBD>ͬ
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>",sum+1);
scanf("%s",p1->problem);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>𰸣<EFBFBD>\n");
for(i=0;i<4;i)
{
printf("%c)",i+'A');
scanf("%s",p1->answer[i++] );
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>𰸣<EFBFBD>");
p1->right =getchar();
scanf("%c",&p1->right );
sum+=1;
printf("\n");
6 years ago
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>\n1.<2E><>\n2.<2E><>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>");
scanf("%d",&n);
if(n==2)
{
p2->next=NULL;
break;
}
system("cls");
6 years ago
}while(n==1);
preservation();
}
6 years ago
void modification() //<2F>޸<EFBFBD><DEB8><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
{
int i,num;
EXAM *p1=NULL;
EXAM *p2=NULL;
6 years ago
experience();
if(sum>=1)
{
p1=(EXAM *)malloc(sizeof(EXAM)); //ΪP1<50><31><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>̬<EFBFBD>ڴ<EFBFBD>
p2=head;
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
for(i=0;i<num-1;i++)
6 years ago
p2=p2->next; //<2F><>ʱp2<70><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2>num-1<><31>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>");
scanf("%s",p1->problem);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>𰸣<EFBFBD>\n");
for(i=0;i<4;)
{
6 years ago
printf("%c)",i+'A');
scanf("%s",p1->answer[i++] );
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>𰸣<EFBFBD>");
p1->right=getchar();
scanf("%c",&p1->right);
6 years ago
p1->next=p2->next->next; //<2F>ڵ<EFBFBD><DAB5><EFBFBD><E6BBBB><EFBFBD>ӳɹ<D3B3>
p2->next=p1; //p1<70><31>p2<70><32><EFBFBD><EFBFBD>
p1=NULL;
p2=NULL; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊĩβ
preservation();
}
}
void Answer() //<2F><><EFBFBD><EFBFBD><E2BAAF>
{
int i,j,c;
int n;
6 years ago
char write;
int score=0;
EXAM *p=NULL;
printf("ף<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
system("cls");
6 years ago
if(sum=0)
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ!\n");
else
{
i=0;
p=head;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
do
{
p=p->next; //<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("%d.%s\n",i+1,p->problem);
c=0;
while(c<4)
{
6 years ago
printf("%c)",c+'A');
printf("%s\n",p->answer[c++] );
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ𰸣<EFBFBD>");
6 years ago
getchar();
scanf("%c",&write);
if(p->right==write)
{
6 years ago
printf("\n<EFBFBD><EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %c <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %c ",write,p->right);
score+=1;
}
else
{
6 years ago
printf("\n̫<EFBFBD><EFBFBD>ϧ<EFBFBD><EFBFBD>~<7E><><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD> %c <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %c ",write,p->right);
}
i=i+1;
printf("\n----------------------------------------------------------\n");
6 years ago
if(i==n) //<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>Ҫ<EFBFBD><D2AA>
break;
}while(p->next!=NULL);
printf("<EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD>!\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d\n<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d\n",n,score);
getch();
;
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
getchar();
}