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.

186 lines
4.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<stdio.h>//出现乱码就把编码改一下,哈哈哈哈
#include<stdlib.h>
#include<string.h>
typedef struct giepaper{
char name[100];
char qa[100];
char qb[100];
char qd[100];
char qc[100];
char answer;
}gie;
typedef struct fensi{
char name[50];
int num;
int grade;
}CLT;
gie k;
gie m[100];
CLT fs[10];
int i=0,t=0,j=0;//i代表题数t代表人数 j代表答对的题数
int itry();
void savingfile();
void adding();
void reveal();
int main(){
char ch;
int h;
FILE *fp1;
fp1=fopen("giegie.txt","a+");
printf("************************\n");
printf("*欢迎使用giegie答题系统*\n");
printf("************************\n");
printf("创作者:韬子同学\n");
printf("按回车键进入系统\n");
getchar();
if(fp1==NULL){
printf("无法打开该文件:giegie.txt:(\n");
exit(0);
}
while(!feof(fp1)){
fscanf(fp1,"%s %s %s %s %s %c ",k.name,k.qa,k.qb,k.qc,k.qd,&k.answer);//为什么最后得加一个空格???
//printf("%s %s %s %s %s \n",k.name,k.qa,k.qb,k.qc,k.qd);
i++;
}
rewind(fp1);
for(int a=0;a<i;a++){
fscanf(fp1,"%s %s %s %s %s %c ",m[a].name,m[a].qa,m[a].qb,m[a].qc,m[a].qd,&m[a].answer);
}
printf("是否进入多人作答模式Y/y进入N/n进入单人作答模式\n");
ch=getchar();
getchar();
if(ch=='Y'||ch=='y'){
printf("请输入您要录入的人数\n");
scanf("%d",&t);//人数
getchar();
for(int a=0;a<t;a++){
printf("请输入%d位真爱粉的信息\n",a+1);
printf("前面代表名字,后面代表号码\n");
scanf("%s %d",fs[a].name,&fs[a].num);
}
printf("您准备好了吗?\n");
printf("答题准备开始\n");
printf("祝您答题愉快\n");
getchar();
printf("本套题共有%d题\n",i);
printf("作答时答案一定需要大写,否则作答无效\n");
for(int b=0;b<t;b++){
printf("轮到%d位真爱粉作答",b+1);
fs[b].grade=itry(t);
}
}else{
t=1;
printf("您选择了单人作答\n");
printf("请输入您作为真爱粉的信息\n");
printf("前面代表名字,后面代表号码\n");
scanf("%s %d",fs[0].name,&fs[0].num);
printf("您准备好了吗?\n");
printf("答题准备开始\n");
printf("祝您答题愉快\n");
getchar();
printf("本套题共有%d题\n",i);
printf("作答时答案一定需要大写,否则作答无效\n");
fs[0].grade=itry(t);
}
for(int b=0;b<t;b++){
printf("第%d位同学的成绩为%d\n",b+1,fs[b].grade);
}
printf("即将进入更好van的排名信息\n");
getchar();
for(int b=0;b<t;b++){
printf("%s同学,",fs[b].name);
if(fs[b].grade==90||fs[b].grade==100){
printf("名副其实的真爱粉!\n");
}
else if(fs[b].grade==0){
printf("是小黑子吧,啊哈哈哈\n");
}
else{
printf("还差一点就能成为真爱粉了,努努力吧!\n");
}
}
printf("即将进入附加功能…………\n");
while(1){
printf("*******1.查看题库****2.增加题目*******\n");
printf("*********输入其他默认退出系统*********\n");
printf("请输入您需要选择的功能的编码:\n");
scanf("%d",&h);
getchar();
switch(h){
case 1: reveal();//输出题库
break;
case 2: adding();//增加题目
break;
default:
printf("程序结束,感谢您的使用!\n");
return 0;
}
}
rewind(fp1);
savingfile();
fclose(fp1);
//printf("%d",i);
return 0;
}
int itry(int t){
char key;
int count=0;
for(int a=0;a<i;a++){
printf("第%d题\n",a+1);
printf("%s\n",m[a].name);
printf("%s\n",m[a].qa);
printf("%s\n",m[a].qb);
printf("%s\n",m[a].qc);
printf("%s\n",m[a].qd);
printf("请输入您的答案:\n");
key=getchar();
getchar();
system("cls");
if(key==m[a].answer){
count+=10;
}
}
return count;
}
void adding(){
printf("请输入题干:\n");
gets(m[i].name);
printf("请输入A选项的内容:\n");
gets(m[i].qa);
printf("请输入B选项的内容:\n");
gets(m[i].qb);
printf("请输入C选项的内容:\n");
gets(m[i].qc);
printf("请输入D选项的内容:\n");
gets(m[i].qd);
printf("请输入正确答案:\n");
m[i].answer=getchar();
i++;
}
void reveal(){
for(int a=0;a<i;a++){
printf("第%d题\n",a+1);
printf("%s\n",m[a].name);
printf("%s\n",m[a].qa);
printf("%s\n",m[a].qb);
printf("%s\n",m[a].qc);
printf("%s\n",m[a].qd);
}
}
void savingfile(){
FILE *fp2;
fp2=fopen("newgiegie.txt","r+");
if(fp2==NULL){
printf("文件newgiegie.txt打不开\n");
}
for(int a=0;a<i;a++){
fprintf(fp2,"%s %s %s %s %s %c ",m[a].name,m[a].qa,m[a].qb,m[a].qc,m[a].qd,&m[a].answer);
}
fclose(fp2);//没有执行就没有内容
}