|
|
|
@ -1,81 +0,0 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<malloc.h>
|
|
|
|
|
#include<stdlio.h>
|
|
|
|
|
#define TRUE 1
|
|
|
|
|
#define ERROR 0
|
|
|
|
|
#define MAX 30
|
|
|
|
|
typedef int Status;
|
|
|
|
|
typedef struct{
|
|
|
|
|
char option1[30],option2[30],option3[30],option4[30],subject[150];
|
|
|
|
|
char result;
|
|
|
|
|
}TestNode;
|
|
|
|
|
TestNode Testquestions[MAX];
|
|
|
|
|
|
|
|
|
|
Staus SaveNode(int N) //把结构体数组保存到文件“单项选择题考试题库”中
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
if((fp=fopen("单项选择题考试题库","wb"))==NULL)
|
|
|
|
|
return ERROR;
|
|
|
|
|
for(i=0;i<N;i++)
|
|
|
|
|
fwrite(&Testquestions[i],sizeof(TestNode),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Status ReadNode(int &N) //从文件中读出结构体数组的内容
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i=0;
|
|
|
|
|
if((fp=fopen("单项选择题考试题库","rb"))==NULL)
|
|
|
|
|
return ERROR;
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
{
|
|
|
|
|
fread(&Testquestions[i],sizeof(TestNode),1,fp);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
N=i-1;
|
|
|
|
|
return TURE;
|
|
|
|
|
}
|
|
|
|
|
void InputTitle(int N) //输入N道试题
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0;i<N;i++)
|
|
|
|
|
printf("请输入第%d道题目,题干和选项\n",i+1);
|
|
|
|
|
printf("请输入题目:");
|
|
|
|
|
gets(Testquestions[i].subject);
|
|
|
|
|
printf("请输入选项A:");
|
|
|
|
|
gets(Testquestion[i].option1);
|
|
|
|
|
printf("请输入选项B:");
|
|
|
|
|
gets(Testquestion[i].option2);
|
|
|
|
|
printf("请输入选项C:");
|
|
|
|
|
gets(Testquestion[i].option3);
|
|
|
|
|
printf("请输入选项D:");
|
|
|
|
|
gets(Testquestion[i].option4);
|
|
|
|
|
printf("请输入答案:");
|
|
|
|
|
scanf(%c,&Testquestion[i].result);
|
|
|
|
|
getchar();
|
|
|
|
|
system("cls"); //清屏
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Status InsertNode(int &N) //插入试题内容
|
|
|
|
|
{
|
|
|
|
|
if(N>MAX)
|
|
|
|
|
return ERROR;
|
|
|
|
|
printf("请输入所要插入的题目,题干和选项:\n");
|
|
|
|
|
printf("请输入题目:");
|
|
|
|
|
gets(Testquestions[N].subject);
|
|
|
|
|
printf("请输入选项A:");
|
|
|
|
|
gets(Testquestion[N].option1);
|
|
|
|
|
printf("请输入选项B:");
|
|
|
|
|
gets(Testquestion[N].option2);
|
|
|
|
|
printf("请输入选项C:");
|
|
|
|
|
gets(Testquestion[N].option3);
|
|
|
|
|
printf("请输入选项D:");
|
|
|
|
|
gets(Testquestion[N].option4);
|
|
|
|
|
printf("请输入答案:");
|
|
|
|
|
scanf(%c,&Teatquestion[N].result);
|
|
|
|
|
getchar();
|
|
|
|
|
N++;
|
|
|
|
|
return TURE;
|
|
|
|
|
}
|