#include<stdio.h>
#include<stdlib.h> int main(){ int right=0; int wrong=0; int choise; int s=0;printf("简易四则运算\n\n");
printf("请选择:加法输入1,减法输入2,乘法输入3,除法输入4,退出运算5\n");
while(s==0)
{ scanf("%d",&choise); switch(choise) { case 1: { int a,b,c; a=1+rand()%100; b=1+rand()%100; printf("请回答:\n\t\t %d + %d = ",a,b); scanf("%d",&c); if(a+b==c) { printf("回答正确!\n"); right++; } else { printf("回答错误!\n"); wrong++; } } break; case 2: { int a,b,c; a=rand()%100; b=rand()%100; printf("请回答:\n\t\t %d - %d = ",a,b); scanf("%d",&c); if(a-b==c) { printf("回答正确!\n"); right++; } else { printf("回答错误!\n"); wrong++; } } break; case 3: { int a,b,c; a=rand()%100; b=rand()%100;printf("请回答:\n\t\t %d * %d = ",a,b);
scanf("%d",&c); if(a*b==c) { printf("回答正确!\n"); right++; } else { printf("回答错误!\n"); wrong++; } } break; case 4: { int a,b,c; a=rand()%100; b=1+rand()%100; int y=0; while(y<1000) { y++; if(a%b==0) {printf("请回答:\n\t\t %d / %d = ",a,b);
scanf("%d",&c); if(a/b==c) { printf("回答正确!\n"); right++; } else { printf("回答错误!\n"); wrong++; }break;
} else { a=rand()%100; b=1+rand()%100; } } } break; case 5:printf("您总共完成了 %d 道题\n正确 %d 道\n错误 %d 道\n",right+wrong,right,wrong); default:printf("enter data error!"); } } return 0;}截图: