#includestdio.h#includestring.h#includestdlib.h#includemath.h#includetime.hvoidcd();//菜单voidgz();//游戏规则函数voidadd();//个位数加法voidadd1();//十位数加法voidsub();//个位数减法voidsub1();//十位数减法voidmul();//个位数乘法voidmul1();//十位数乘法voiddiv();//个位数除法voiddiv1();//十位数除法voidtc();//退出函数intsum=0,k;main(){cd();return0;}voidcd()//菜单{intz;printf(\n);printf(菜单\n);printf(0.规则\n);printf(1.加法\n);printf(2.减法\n);printf(3.乘法\n);printf(4.除法\n);printf(\n);printf(请选择\n);scanf(%d,&z);if(z9||z0){printf(输入错误!请重新输入!\n);scanf(%d,&z);}switch(z){case0:gz();break;case1:add();break;case2:sub();break;case3:mul();break;case4:div();break;default:tc();}}voidgz()//游戏规则函数{intl;printf(\n);printf(游戏规则\n);printf(1、你可以选择加法,减法,乘法,除法,运算四种运算。\n);printf(2、每种运算分为两个等级,第一级和第二级\n);printf(3、第一级为个位数运算,第二级为十位数运算。\n);printf(4、做第一级正确率达到90%,将进入第二级。\n);printf(5、若在第二级的正确率低于60%将会降级。\n);printf(\n);printf(输入(0)返回菜单\n);scanf(%d,&l);if(l=9||l0){printf(输入错误!请重新输入!\n);printf(是否继续挑战?\n);printf(Yes(0)继续挑战,No(1)结束!\n);scanf(%d,&l);}switch(l){case0:cd();break;default:tc();}}voidadd()//个位数加法{intx,y,i,j;floatanswer;intsum=0;//统计一次答对的题数sumprintf(请输入挑战的题量:);//输入的题目数量kscanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));//用当前时间作参数,计算随机数种子x=(rand()%10);//取0~9之间的随机数y=(rand()%10);printf(%d+%d=,x,y);scanf(%f,&answer);if(answer!=(x+y)){j=1;while(answer!=(x+y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d+%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=((float)x+(float)y));}else{printf(回答正确!\n);}}else{sum++;printf(回答正确!\n);}}printf(答对题数:%d答错题数:%d一次答对率为:%5.2f%%\n,sum,(k-sum),(sum/(float)k*100));if((sum/(float)k)=0.9){printf(恭喜您晋级了!\n);add1();}else{printf(抱歉您未能晋级\n);tc();}}voidadd1()//十位数加法{intx,y,i,k,j,sum=0;floatanswer;printf(请输入挑战的题量:);scanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));x=(rand()%90+10);y=(rand()%90+10);printf(%d+%d=,x,y);scanf(%f,&answer);if(answer!=(x+y)){j=1;while(answer!=(x+y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d+%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=((float)x+(float)y));}else{printf(回答正确!\n);}}else{sum++;printf(回答正确!\n);}}printf(答对题数:%d答错题数:%d一次答对率为:%5.2f%%\n,sum,(k-sum),(sum/(float)k*100));if((sum/(float)k)0.6){printf(很抱歉,您降级了!回到第一级!\n);add();}else{printf(恭喜您,顺利通关!\n);tc();}}voidsub()//个位数减法{intx,y,i,k,j,sum=0;floatanswer;printf(请输入挑战的题量:);scanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));loop://配合goto转跳{x=(rand()%10);y=(rand()%10);}if(x=y){printf(%d-%d=,x,y);scanf(%f,&answer);if(answer!=(x-y)){j=1;while(answer!=(x-y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d-%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=((float)x-(float)y));}else{printf(回答正确!\n);}}else{sum++;printf(回答正确!\n);}}elsegotoloop;}printf(答对题数:%d答错题数:%d一次答对率为:%5.2f%%\n,sum,(k-sum),(sum/(float)k*100));if((sum/(float)k)=0.9){printf(恭喜您晋级了!\n);sub1();}else{printf(抱歉您未能晋级!\n);tc();}}voidsub1()//十位数减法{intx,y,i,k,j,sum=0;floatanswer;printf(请输入挑战的题量:);scanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));loop:{x=(rand()%90+10);y=(rand()%90+10);}if(x=y){printf(%d-%d=,x,y);scanf(%f,&answer);if(answer!=(x-y)){j=1;while(answer!=(x-y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d-%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=((float)x-(float)y));}else{printf(回答正确!\n);}}else{sum++;printf(回答正确!\n);}}elsegotoloop;}printf(答对题数:%d答错题数:%d一次答对率为:%5.2f%%\n,sum,(k-sum),(sum/(float)k*100));if((sum/(float)k)0.6){printf(很抱歉,您降级了!回到第一级!\n);sub();}else{printf(恭喜您,顺利通关!\n);tc();}}voidmul()//个位数乘法{intx,y,k,i,j,sum=0;floatanswer;printf(请输入挑战的题量:);scanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));x=(rand()%10);y=(rand()%10);printf(%d*%d=,x,y);scanf(%f,&answer);if(answer!=(x*y)){j=1;while(answer!=(x*y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d*%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=((float)x*(float)y));}else{printf(回答正确!\n);}}else{sum++;printf(回答正确!\n);}}printf(答对题数:%d答错题数:%d一次答对率为:%5.2f%%\n,sum,(k-sum),(sum/(float)k*100));if((sum/(float)k)=0.9){printf(恭喜您晋级了!\n);mul1();}else{printf(抱歉您未能晋级!);tc();}}voidmul1()//十位数乘法{intx,y,i,k,j,sum=0;floatanswer;printf(请输入挑战的题量:);scanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));x=(rand()%90+10);y=(rand()%90+10);printf(%d*%d=,x,y);scanf(%f,&answer);if(answer!=(x*y)){j=1;while(answer!=(x*y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d*%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=((float)x*(float)y));}else{printf(回答正确!\n);}}else{sum++;printf(回答正确!\n);}}printf(答对题数:%d答错题数:%d一次答对率为:%5.2f%%\n,sum,(k-sum),(sum/(float)k*100));if((sum/(float)k)0.6){printf(很抱歉,您降级了!回到第一级!\n);mul();}else{printf(恭喜您,顺利通关!\n);tc();}}voiddiv()//个位数除法{intx,y,i,k,j;intanswer;intsum=0;printf(请输入挑战的题量:);scanf(%d,&k);for(i=1;i=k;i++){srand((unsigned)time(0));do{x=(rand()%10);y=(rand()%10);}while(y==0||x%y!=0);printf(%d/%d=,x,y);scanf(%d,&answer);if(answer!=(x/y)){j=1;while(answer!=(x/y)&&j3){printf(答案错误,请输入正确答案:\n);printf(%d/%d=,x,y);scanf(%f,&answer);j++;}if(j=3){printf(正确答案:\n);printf(%f\n,answer=(x/y));}else{printf(回答正确!\n)