小学计算题生成器横式(C语言版)

#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("      ------------
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值