#include #include #include #include int pd(int a,int b); void pj(int x); int sx (void); int main() { int i = 0; char password[20] = {0}; for(i=0; i<3; i++) { printf("请输入密码: "); scanf("%s", password); if(0 == strcmp(password, "123456")) { break; } else { printf("密码输入错误,请再次输入!\n"); } } if(i<3) { printf("登录成功\n"); printf("开始测试\n"); sx(); } else printf("退出程序\n"); return 0; } int sx (void) { int dyx,dex,jsjg,srjg,j,x,sum; sum=0; srand((unsigned)time(NULL)); for(j=1;j<=10;j++) { int q; q=rand()%2; switch(q) { case 1: dyx=rand()%25+1; dex=rand()%25+1; jsjg=dyx+dex; printf("%d+%d=",dyx,dex); scanf("%d",&srjg); x=pd(srjg,jsjg); break; case 0: dyx=rand()%50+1; dex=rand()%50+1; if(dyx>=dex) { jsjg=dyx-dex; printf("%d-%d=",dyx,dex); scanf("%d",&srjg); x=pd(srjg,jsjg); break; } else { jsjg=dex-dyx; printf("%d-%d=",dex,dyx); scanf("%d",&srjg); x=pd(srjg,jsjg); break; } } sum+=x; } pj(sum); return 0; } int pd(int a,int b) { int fs,i,xdjg; if(a==b) i=0; else { for(i=1;i<3;i++) { printf("答案错误,请重新输入:"); scanf("%d",&xdjg); a=xdjg; if(a==b) break; } } switch(i) { case 0:fs=10;break; case 1:fs=7;break; case 2:fs=5;break; default:fs=0;printf("正确答案:%d\n",b); } return fs; } void pj(int x) { int c; c=x/10; switch(c) { case 10:printf("SMART");break; case 9:printf("SMART");break; case 8:printf("GOOD");break; case 7:printf("OK");break; case 6:printf("PASS");break; default:printf("TRY AGAIN"); } }