#include <stdio.h> #include <stdlib.h> #include<math.h> int main(void) { float a; float b;//生成的随机数 float sum[99]={0};//运算过后的结果 int x,y;//随机数生成范围 char k;//运算符号 int mun;//题数 int key;//判断是否工作 printf("input the first number\n"); scanf("%d",&x); printf("Input the second number\n"); scanf("%d",&y); printf("Input operator\n"); getchar();/*吃掉回车*/ scanf("%c",&k); printf("Input the number of generated questions\n"); scanf("%d",&mun); srand(time(0)); while(1) { switch(k) { //加法 case'+': for (int i=1;i<=mun;i++) { a=rand()%x; b=rand()%y; sum[i]=a+b; printf("第%d题:%5f + %5f = \n",i,a,b); printf(" ------------
小学计算题生成器横式(C语言版)
最新推荐文章于 2025-04-27 15:24:11 发布