zoukankan      html  css  js  c++  java
  • 新 四则运算题目 修改

    程序代码;

    #include <stdlib.h>
    #include <iostream.h>
    #include <conio.h>
    #include <time.h>
    using namespace std;
    void Display1(int,int,int);
    void Display2(int [],int,int,int);
    int main()
    {
    int a = 0;
    int b = 0;
    int mode = 0;//0:加 1:减 2:乘 3:除
    int i = 0;
    int c[7]={0,40,1,100,1,1,4};//是否定制,出题数量、是否有乘除、数值上限、数值下限,是否有余数,每行个数。
    srand((unsigned)time( NULL ) ); //初始化随机数发生器,使得每次运行生成的随机数不同
    printf("--------------------------------------------------------------------------- ");
    printf(" 欢迎来到二柱子出题系统! ");
    printf(" 本系统默认生成40道100以内数字的四则运算题目,每行4道 ");
    printf(" 是否定制?是输入1,否输入0:");
    cin>>c[0];
    if(c[0]==0)
    {
    printf("----------------------------题目打印如下------------------------------------ ");
    Display1(a,b,mode) ;
    }
    else
    {
    cout<<" 请输入出题数量:";
    cin>>c[1];
    cout<<" 是否含乘除?是输入1,否输入0:";
    cin>>c[2];
    cout<<" 数值上限:";
    cin>>c[3];
    cout<<" 数值下限:";
    cin>>c[4];
    cout<<" 是否含余数?是输入1,否输入0:";
    cin>>c[5];
    cout<<" 每行题目数:";
    cin>>c[6];
    printf("----------------------------题目打印如下------------------------------------ ");
    Display2(c,a,b,mode);
    }
    printf("--------------------题目打印完毕,谢谢使用---------------------------------- ");
    cout<<endl;
    return 0;
    }
    void Display1(int a,int b,int mode)
    {
    for(int i=0;i<40;i++) //做三十题
    {
    a = rand() % 100; //生成一个0~99之间的随机数
    b = rand() % 100; //生成一个0~99之间的随机数
    mode = rand() % 4; //生成一个0~3之间的随机数,代表运算符
    printf("%d", a); //打印算式
    switch(mode) //确定运算符
    {
    case 0:
    printf("+%d = ", b );
    break;
    case 1:
    printf("-%d = ", b );
    break;
    case 2:
    printf("*%d = ", b );
    break;
    case 3:
    printf("/%d = ", b );
    break;
    default:
    printf("somethingis wrong! ");
    break;
    }
    if((i+1)%4== 0) //判断是否换行
    {
    printf(" ");
    }
    else
    {

    for(int j = 0;j<3;j++)
    {
    printf(" ");
    }
    }
    }
    }
    void Display2(int c[],int a,int b,int mode)
    {
    for(int i=0;i<c[1];i++) //定制题数
    {
    a = rand() % (c[3]-c[4]+1)+c[4]; //生成限定的随机数
    b = rand() % (c[3]-c[4]+1)+c[4]; //生成限定的随机数
    if(c[2]==1)
    {
    mode = rand() % 4; //生成一个0~3之间的随机数,代表运算符
    switch(mode) //确定运算符
    {
    case 0:
    printf("%d+%d = ",a, b );
    break;
    case 1:
    printf("%d-%d = ",a, b );
    break;
    case 2:
    printf("%d*%d = ",a, b );
    break;
    case 3:
    if(c[5] == 1) //判断选择是否有余数,如果能有余数
    {
    printf("%d/%d = ",a, b );
    }
    else if(a%b!=0) //如果不能有余数
    {
    i = i-1;
    }
    else
    {
    printf("%d/%d = ",a, b );
    }
    break;
    default:
    printf("somethingis wrong! ");
    break;
    }
    if((i+1)%c[6]== 0) //判断是否换行
    {
    printf(" ");
    }
    else
    {

    for(int j = 0;j<3;j++)
    {
    printf(" ");
    }
    }
    }
    else{
    mode = rand() % 2; //生成一个0~1之间的随机数,代表运算符
    printf("%d", a); //打印算式
    switch(mode) //确定运算符
    {
    case 0:
    printf("+%d = ", b );
    break;
    case 1:
    printf("-%d = ", b );
    break;
    default:
    printf("somethingis wrong! ");
    break;
    }
    if(i%c[6]== 0) //判断是否换行
    {
    printf(" ");
    }
    else
    {

    for(int j = 0;j<3;j++)
    {
    printf(" ");
    }
    }
    }
    }
    }

    运行截图;

    一、项目计划总结:

     

    周活动总结表

    姓名:翟凯                                          日期:15/3/14

    日期       任务

    听课

    编写程序

    阅读课本

    准备考试

     

     

    日总计

    周日

     

     

     

     

     

     

     

    周一

     

     

     

     

     

     

     

    周二

     300

     

     20

     

     

     

     320

    周三

     100

     70

     30

     

     

     

     200

    周四

     200

     115

     5

     

     

     

     320

    周五

     200

     40

     30

     

     

     

     270

    周六

     

     43

     10

     

     

     

     53

    周总结

     800

     268

     95

     

     

     

     1163

    阶段时间和效率                                            周数(上一次周活动表的周数+1)

     

    以前各周的累计时间                                                                        

    总计

     800

     268

     95

     

     

     

     1163

    平均

     800

     268

     95

     

     

     

     1163

    最大

     800

     268

     95

     

     

     

     1163

    最小

     800

     268

     95

     

     

     

     1163

    不包括上一周在内的累计时间                                                                                  

    总计

     800

     

     

     

     

     

     

    平均

     

     

     

     

     

     

     

    最大

     

     

     

     

     

     

     

    最小

     

     

     

     

     

     

     

    二、时间记录表:

    学生             翟凯                                               日期        15/13/14               

    教师        王建民                                             课程           PSP       

    日期

    开始时间

    结束时间

    中断时间

    净时间

    活动

    备注

     3.11

     14;00

     15;00

     30

     30

     写代码

     

     3.11

     21;00

     22;00

     0

     60

     写代码

     

     3.12

     19;10

     21;00

     20

     100

     写代码

     

     3.13

     15;00

     16;00

     0

     60

     写代码

     

     3.13

     20;30

     22;00

     30

     90

     写代码

     

     3.14

     15;12

     18;00

     72

     120

     写代码

     

    三、缺陷记录日志:

    学生                   

    日期                   

    教员       王建民   

    程序号                

    日期

    编号

    类型

    引入阶段

    排除阶段

    修复时间

    修复缺陷

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    由于周末返校不及时,发表晚了,请见谅

     

  • 相关阅读:
    spring boot-17.RabbitMQ
    spring boot-16.使用redis做缓存
    spring boot-15.缓存
    spring boot-14.集成MyBatis
    spring boot-13.数据访问
    docker 安装完mysql 后客户端无法访问
    【python】string functions
    【转】澄清P问题、NP问题、NPC问题
    ubuntu中使用gensim+word2vec[备忘]
    ubuntu熟悉过程中遇到一些小问题记录一下
  • 原文地址:https://www.cnblogs.com/huazongzong/p/4340616.html
Copyright © 2011-2022 走看看