图片:
代码:
1 #include<stdio.h>
2 #include<stdlib.h>
3
4 int main()
5 {
6 int j=0;
7
8 printf("请选择四则运算的法则:\\n");
9 printf("1.加 2.减 3.乘 4.除\\n");
10 int num;
11 scanf("%d",&num);
12
13 for(int i=0;i<400;i++){
14 int a,b;
15 a = rand()%100+1;
16 b = rand()%100+1;
17
18 if(num==1){
19 printf("%d + %d =\\n",a,b);
20 printf("答案:%d\\n\\n",a+b);
21 }
22 else if(num==2){
23 printf("%d - %d =\\n",a,b);
24 printf("答案:%d\\n\\n",a-b);
25 }
26 else if(num==3){
27 printf("%d × %d =\\n",a,b);
28 printf("答案:%d\\n\\n",a*b);
29 }
30 else {
31 printf("%d ÷ %d =\\n",a,b);
32 printf("答案:%f\\n\\n",a/b);
33 }
34 }
35 }