commit 64a4a793850dfe6ebcde132fcf4e347995d684c8 Author: 1304772892@qq.com <1304772892@qq.com> Date: Tue Jan 8 15:49:02 2019 +0800 first commit diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..2a0ee1f --- /dev/null +++ b/Makefile.win @@ -0,0 +1,43 @@ +# Project: 小学生测验 +# Makefile created by Dev-C++ 5.11 + +CPP = g++.exe +CC = gcc.exe +WINDRES = windres.exe +OBJ = main.o test.o record.o load.o ../pupil_test/save.o setting.o +LINKOBJ = main.o test.o record.o load.o ../pupil_test/save.o setting.o +LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc +INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" +CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" +BIN = 小学生测验.exe +CXXFLAGS = $(CXXINCS) -std=c99 +CFLAGS = $(INCS) -std=c99 +RM = rm.exe -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before $(BIN) all-after + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +$(BIN): $(OBJ) + $(CC) $(LINKOBJ) -o $(BIN) $(LIBS) + +main.o: main.c + $(CC) -c main.c -o main.o $(CFLAGS) + +test.o: test.c + $(CC) -c test.c -o test.o $(CFLAGS) + +record.o: record.c + $(CC) -c record.c -o record.o $(CFLAGS) + +load.o: load.c + $(CC) -c load.c -o load.o $(CFLAGS) + +../pupil_test/save.o: ../pupil_test/save.c + $(CC) -c ../pupil_test/save.c -o ../pupil_test/save.o $(CFLAGS) + +setting.o: setting.c + $(CC) -c setting.c -o setting.o $(CFLAGS) diff --git a/load.c b/load.c new file mode 100644 index 0000000..0889804 --- /dev/null +++ b/load.c @@ -0,0 +1,21 @@ +#include"main.h" + +load(int v){ + + dif=0; + + FILE *precord=fopen("record.txt","r"); + + fscanf(precord,"%d%d%d",&range,&kind,&voice); + + if(range==1) dif+=2; + if(kind==1) dif++; + + for(int i=0;i<4;i++){ + for(int j=0;j<10;j++){ + fscanf(precord,"%s%d%f",&dates[i][j].name,&dates[i][j].scores,&dates[i][j].time); + } + } + fclose(precord); + +} diff --git a/load.o b/load.o new file mode 100644 index 0000000..4aec50b Binary files /dev/null and b/load.o differ diff --git a/main.c b/main.c new file mode 100644 index 0000000..695bcf7 --- /dev/null +++ b/main.c @@ -0,0 +1,47 @@ +#include"main.h" + +int range,kind,voice,dif; +date dates[4][11]; + + +int main(void){ + + char choice; + srand(time(NULL)); + + load(1); + + do{ + + printf("\n\n\n\n\n\n\t\t\t欢迎使用小学生测验\n\n"); + printf("\t\t\t1.开始测验\n\n"); + printf("\t\t\t2.排名\n\n"); + printf("\t\t\t3.设置\n\n"); + printf("\t\t\t4.退出\n\n"); + printf("\t\t\t(输入选项前数字进行相应的操作)\n\n\t\t\t"); + + do{ //选择判断 + + choice=getch(); if(voice==1) printf("\a"); + + + if(choice>='1'&&choice<='4'){ + + system("cls"); + + if(choice=='1') test(1); + if(choice=='2') record(1); + if(choice=='3') setting(1); + break; + + }else printf("\n\t\t\t输入错误\n\n\t\t\t"); + + }while(choice!='4'); + + }while(choice!='4'); + + save(1); + + return 0; + +} diff --git a/main.exe b/main.exe new file mode 100644 index 0000000..4dd8477 Binary files /dev/null and b/main.exe differ diff --git a/main.h b/main.h new file mode 100644 index 0000000..abe82cf --- /dev/null +++ b/main.h @@ -0,0 +1,19 @@ +#include +#include +#include +#include +#include + +typedef struct date{ + char name[11]; + int scores; + float time; +}date; + +extern int range,kind,voice,dif; +extern date dates[4][11]; + +test(int v); +record(int v); +load(int v); +save(int v); diff --git a/main.o b/main.o new file mode 100644 index 0000000..ce4a3f1 Binary files /dev/null and b/main.o differ diff --git a/record.c b/record.c new file mode 100644 index 0000000..cccaa2e --- /dev/null +++ b/record.c @@ -0,0 +1,20 @@ +#include"main.h" + +record(int v){ + + if(range==0) printf("\n\t\t\t\t100以内"); + else printf("\n\t\t\t\t1000以内"); + if(kind==0) printf("加减法\n\n"); + else printf("乘除法\n\n"); + + printf("\t\t\t排名 名字 成绩 时间\n\n"); + + for(int i=0;i<10;i++){ + printf("\t\t\t%2d. %-5s %3d分 %5.2f秒\n\n",i+1,dates[dif][i].name,dates[dif][i].scores,dates[dif][i].time); + } + + printf("\t\t\t按任意键返回菜单"); + getch(); if(voice==1) printf("\a"); + system("cls"); + +} diff --git a/record.o b/record.o new file mode 100644 index 0000000..bee1ecf Binary files /dev/null and b/record.o differ diff --git a/record.txt b/record.txt new file mode 100644 index 0000000..d5c0393 --- /dev/null +++ b/record.txt @@ -0,0 +1,41 @@ +0 0 0 +罗聪 100 57.33 +罗聪 60 40.73 +罗聪 10 10.45 +crf 10 13.91 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 +0 0 0.00 diff --git a/save.c b/save.c new file mode 100644 index 0000000..c30a17e --- /dev/null +++ b/save.c @@ -0,0 +1,15 @@ +#include"main.h" + +save(int v){ + + FILE *precord=fopen("record.txt","w"); + + fprintf(precord,"%d %d %d\n",range,kind,voice); + for(int i=0;i<4;i++){ + for(int j=0;j<10;j++){ + fprintf(precord,"%s %d %.2f\n",dates[i][j].name,dates[i][j].scores,dates[i][j].time); + } + } + fclose(precord); + +} diff --git a/save.o b/save.o new file mode 100644 index 0000000..0f7d78b Binary files /dev/null and b/save.o differ diff --git a/setting.c b/setting.c new file mode 100644 index 0000000..6726e8b --- /dev/null +++ b/setting.c @@ -0,0 +1,63 @@ +#include"main.h" + +void setting(int v){ + + char choice; + + do{ + + printf("\n\n\n\n\n\n\t\t\t\t设置\n\n"); + printf("\t\t\t1.范围····> "); + if(range==0) printf("100以内\n\n"); + else printf("1000以内\n\n"); + printf("\t\t\t2.运算符···> "); + if(kind==0) printf("加减\n\n"); + else printf("乘除\n\n"); + printf("\t\t\t3.声音····> "); + if(voice==0) printf("关\n\n"); + else printf("开\n\n"); + printf("\t\t\t4.返回菜单\n\n"); + + do{ //选择判断 + + choice=getch(); + + if(choice>='1'&&choice<='4'){ + + if(choice=='1'){ + + range++; + range%=2; + + } + + if(choice=='2'){ + + kind++; + kind%=2; + + } + + if(choice=='3'){ + + voice++; + voice%=2; + + } + + if(voice==1) printf("\a"); + break; + + }else printf("\n\t\t\t输入错误\n\n\t\t\t"); + + }while(choice!='4'); + + system("cls"); + + }while(choice!='4'); + + dif=0; + if(range==1) dif+=2; + if(kind==1) dif++; + +} diff --git a/setting.o b/setting.o new file mode 100644 index 0000000..18b88a5 Binary files /dev/null and b/setting.o differ diff --git a/test.c b/test.c new file mode 100644 index 0000000..9b031ad --- /dev/null +++ b/test.c @@ -0,0 +1,196 @@ +#include"main.h" + +test(int v){ //测验函数 + + date max; + + int a,b; + int sign; + int scores=0; + int ran=100; + int sta=0; + double time; + char question[22],wro_set[222]; + char truth[11],answer[11]; + + if(range==1) ran=1000; + + clock_t start,end; + + printf("\n\n\n\n\n\n"); + + for(int i=3;i>0;i--){ + printf("\t\t\t测验将在%d秒后开始\n\n",i); if(voice==1) printf("\a"); + sleep(1); + } + + system("cls"); + + start=clock(); + + for(int i=0;i<10;i++){ //随机出题 + + printf("\n\n\n\n\n\n\n\t\t\t(输入exit直接退出测验)"); + + if(kind==0){ + + do{ + + a=rand()%(ran-ran/10)+ran/10+1; + b=rand()%(ran-ran/10)+ran/10+1; + sign=rand()%2; + if(sign==0) sign=-1; + + }while((a+sign*b)ran); + + sprintf(truth,"%d",a+sign*b); + + if(sign==1) sprintf(question,"\n\n\t\t\t第%-2d题:%d+%d=",i+1,a,b); + if(sign==-1) sprintf(question,"\n\n\t\t\t第%-2d题:%d%d=",i+1,a,-1*b); + + }else{ + + do{ + + a=rand()%(ran-4)+3; + b=rand()%(ran-4)+3; + sign=rand()%2; + if(sign==0){ + if((a/b)>=3&&(a/b)<=ran&&(a%b==0)) + break; + }else{ + if((a*b)>=10&&(a*b)<=ran) + break; + } + + }while(1); + + if(sign==0) sprintf(truth,"%d",a/b); + else sprintf(truth,"%d",a*b); + + if(sign==0) sprintf(question,"\n\n\t\t\t第%-2d题:%d/%d=",i+1,a,b); + else sprintf(question,"\n\n\t\t\t第%-2d题:%d*%d=",i+1,a,b); + + } + + printf("%s",question); + + for(int j=2;j>=0;j--){ + + + printf("\n\n\t\t\t您的答案是:"); + + scanf("%s",&answer); if(voice==1) printf("\a"); + + if((strcmp(answer,"exit"))==0) goto exit; + + if((strcmp(answer,truth))==0){ + + if(j==2) scores+=10; + if(j==1) scores+=7; + if(j==0) scores+=5; + printf("\t\t\t答案正确\n\n"); + break; + + }else{ + printf("\t\t\t答案错误 您还有%d次机会",j); + if(j==0){ + sta=1; + strcat(wro_set,question); + strcat(wro_set,truth); + } + } + } + + system("cls"); + + } + + end=clock(); + time=(float)(end-start)/CLK_TCK; + + + if(sta==1){ + + system("cls"); + printf("\n\n\n\n\n\n\t\t\t本次测验错题%s",wro_set); + printf("\n\n\t\t\t按下任意键继续"); + getch(); + system("cls"); + + } + + printf("\n\n\n\n\n\n\t\t\t测验结束,您的成绩是:\n\n\t\t\t%d分 ",scores); + switch(scores/10){ //等级判定 + + case 10:{ + printf("满分"); + break; + } + + case 9:{ + printf("优秀"); + break; + } + + case 8:{ + printf("良好"); + break; + } + + case 7: + case 6:{ + printf("及格"); + break; + } + + default :{ + printf("不及格"); + break; + } + + } + printf(" 用时%.2f秒\n\n",time); + + printf("\t\t\t输入你的名字后返回菜单\n\n"); + printf("\t\t\t君的名字:"); + scanf("%s",&dates[dif][10].name); if(voice==1) printf("\a"); + + dates[dif][10].scores=scores; + dates[dif][10].time =time; + + for(int i=0;i<10;i++){ + + max=dates[dif][i]; + + for(int j=i+1;j<11;j++){ + + if(max.scoresdates[dif][j].time){ + + max =dates[dif][j]; + dates[dif][j]=dates[dif][i]; + dates[dif][i]=max; + + } + + } + + } + + } + + exit: + + system("cls"); + +} diff --git a/test.o b/test.o new file mode 100644 index 0000000..9bdbe54 Binary files /dev/null and b/test.o differ diff --git a/灏忓鐢熸祴楠.dev b/灏忓鐢熸祴楠.dev new file mode 100644 index 0000000..869ff0a --- /dev/null +++ b/灏忓鐢熸祴楠.dev @@ -0,0 +1,122 @@ +[Project] +FileName=小学生测验.dev +Name=小学生测验 +Type=1 +Ver=2 +ObjFiles= +Includes= +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler= +CppCompiler= +Linker= +IsCpp=0 +Icon= +ExeOutput= +ObjectOutput= +LogOutput= +LogOutputEnabled=0 +OverrideOutput=0 +OverrideOutputName= +HostApplication= +UseCustomMakefile=0 +CustomMakefile= +CommandLine= +Folders= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000000000 +UnitCount=7 + +[VersionInfo] +Major=1 +Minor=0 +Release=0 +Build=0 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 +SyncProduct=1 + +[Unit1] +FileName=main.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=test.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=main.h +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=record.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=load.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=save.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit7] +FileName=setting.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/灏忓鐢熸祴楠.exe b/灏忓鐢熸祴楠.exe new file mode 100644 index 0000000..64897d4 Binary files /dev/null and b/灏忓鐢熸祴楠.exe differ diff --git a/灏忓鐢熸祴楠.layout b/灏忓鐢熸祴楠.layout new file mode 100644 index 0000000..406cda8 --- /dev/null +++ b/灏忓鐢熸祴楠.layout @@ -0,0 +1,38 @@ +[Editors] +Order=0,1,3,4,5,6,2 +Focused=2 +[Editor_0] +CursorCol=4 +CursorRow=38 +TopLine=5 +LeftChar=1 +[Editor_1] +CursorCol=24 +CursorRow=124 +TopLine=154 +LeftChar=1 +[Editor_2] +CursorCol=13 +CursorRow=10 +TopLine=1 +LeftChar=1 +[Editor_3] +CursorCol=2 +CursorRow=9 +TopLine=1 +LeftChar=1 +[Editor_4] +CursorCol=2 +CursorRow=8 +TopLine=1 +LeftChar=1 +[Editor_5] +CursorCol=2 +CursorRow=15 +TopLine=1 +LeftChar=1 +[Editor_6] +CursorCol=8 +CursorRow=59 +TopLine=1 +LeftChar=1