#include<stdio.h> #include<stdlib.h> main() {int a,b,op,os; printf(" [每课一练 妈妈再也不用担心我的学习]\n"); aq1: printf("选择您想挑战的运算法则\n");/*新版本跟新如下*/ printf("0.退出 1.加法 2.减法 3.乘法 4.除法 5.做分数题\n");/*添加退出功能*//*增加分数计算*//*增加随机数范围0~100*/ scanf("%d",&op); if(op==0) exit; switch(op) { aq: case 1: a=rand()%100;b=rand()%100; printf("题目为:%d + %d = ?\n\n",a,b); printf("1.查看答案 2.做下一题\n"); scanf("%d",&os); if(os==1) {printf("%d + %d =%d\n\n\n",a,b,a+b); goto aq1; } else goto aq; break; at: case 2:a=rand()%100;b=rand()%100; printf("题目为:%d - %d = ?\n\n",a,b); printf("1.查看答案 2.做下一题\n"); scanf("%d",&os); if(os==1) {printf("%d - %d =%d\n\n\n",a,b,a-b); goto aq1; } else goto at; break; aq2: case 3: a=rand()%100;b=rand()%100; printf("题目为:%d * %d = ?\n\n",a,b); printf("1.查看答案 2.做下一题\n"); scanf("%d",&os); if(os==1) {printf("%d * %d =%d\n\n\n",a,b,a*b); goto aq1; } else goto aq2; break; aq3: case 4: a=rand()%100;b=rand()%100; printf("题目为:%d / %d = ?\n\n",a,b); printf("1.查看答案 2.做下一题\n"); scanf("%d",&os); if(os==1) {printf("%d / %d =%d\n\n\n",a,b,a/b); goto aq1; } else goto aq3; break; aq5: case 5: a=rand()%100;b=rand()%100; printf("题目为:%d / %d = ?\n\n",a,b); printf("1.查看答案 2.做下一题\n"); scanf("%d",&os); if(os==1) {printf("%d / %d =%d\n\n\n",a,b,a/b); goto aq1; } else goto aq5; } }
时间: 2024-11-12 16:58:21