#include #include #include int num=0,num1=0; int m[1000][100]; char oper[4]={'指铅物+','-','*','/'}; int main() { int a,b,c,d,e,flag,i,j; for(i=1;i<=1000;++i) for(j=1;j<=i;++j) if(i%j==0) m[i][m[i][0]++]=j; srand(time(0)); while(1) { system("cls"); printf("当前答题数:%d 正确数:%d 正确率唯液:%.2lf%%\n",num,num1,num?num1*1.0/num*100:0); flag=0; c=rand()%4; while(1) { flag=0; if(c<3) { a=rand()%1000;b=rand()%1000; } else { a=rand()%1000; b=rand()%m[a][0]; b=m[a][b]; } switch(c) { case 0: if(a+b=b) flag=1,d=a-b; break; case 2: if(a*b<=1000) flag=1,d=a*b; break; case 3: if(a%b==0) flag=1,d=a/b; break; } if(flag) break; } printf("%d%c%d=?\n",a,oper[c],b); num++; scanf("%d",&e); if(e==d) { printf("恭喜你回答正确!\n"); num1++; } else { printf("很遗憾,回答错误,正确答案是%d\n",d); } system("激肆pause"); } }