zoukankan      html  css  js  c++  java
  • 《四则运算》

    (1)代码

    //四则运算

    #include<iostream>
    using namespace std;

    int main()
    {
    int a,b,c,d,e,f,g,h,i,j,k,l[1000],m,n[1000],o;

    cout << "请输入所需要的题目的数目:";
    cin >> a;
    cout << "请选择打印的每页有多少题:";
    cin >> f;
    cout << "请选择是否支持负数(1.支持 2.不支持):";
    cin >> g;
    if (g == 1)
    {
    do
    {
    cout << "请输入数值范围(第一个数小于第二个数):";
    cin >> b >> c;
    } while (b >= 0);
    }
    if (g == 2)
    {
    cout << "请输入数值范围(第一个数小于第二个数):";
    cin >> b >> c;
    }
    cout << "请选择是否有乘除法(1.有 2.没有):";
    cin >> d;
    if (d == 1)
    {
    cout << "请选择除法有无余数(1.有 2.没有):";
    cin >> e;
    for (m = 0; m < a; m++)
    {
    l[m] = rand() % (c - b + 1) + b;
    n[m] = rand() % (c - b + 1) + b;
    h = rand() % 4;
    if (e == 1)
    {
    if (h == 0)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "+" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "+" << "("<<n[m]<<")" << "=" << endl;
    }
    }
    if (h == 1)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "-" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "-" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 2)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "*" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "*" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 3)
    {
    if (n[m] == 0)
    {
    m = m - 1;
    }
    else
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "/" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "/" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    }
    }
    if (e == 2)
    {
    if (n[m] <= 0)
    {
    n[m] = -n[m];
    }
    if (l[m] <= 0)
    {
    l[m] = -l[m];
    }
    if (l[m] % n[m] != 0)
    {
    m = m - 1;
    }
    if (l[m] % n[m] == 0)
    {
    if (h == 0)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "+" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "+" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 1)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "-" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "-" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 2)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "*" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "*" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 3)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "/" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "/" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    }
    }
    if ((m + 1) % f == 0)
    {
    cout << endl;
    cout << endl;
    }
    }
    }
    if (d == 2)
    {
    cout << "请选择除法有无余数(1.有 2.没有):";
    cin >> e;
    for (m = 0; m < a; m++)
    {
    l[m] = rand() % (c - b + 1) + b;
    n[m] = rand() % (c - b + 1) + b;
    h = rand() % 2;
    if (e == 1)
    {
    if (h == 0)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "+" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "+" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 1)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "-" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "-" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    }
    if (e == 2)
    {
    if (l[m] % n[m] != 0)
    {
    m = m - 1;
    }
    if (l[m] % n[m] == 0)
    {
    if (h == 0)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "+" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "+" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    if (h == 1)
    {
    if (n[m] >= 0)
    {
    cout << l[m] << "-" << n[m] << "=" << endl;
    }
    if (n[m] < 0)
    {
    cout << l[m] << "-" << "(" << n[m] << ")" << "=" << endl;
    }
    }
    }
    }
    if ((m + 1) % f == 0)
    {
    cout << endl;
    cout << endl;
    }
    }
    }
    }

    (2)截图:

    (3)开发过程

    先对各个条件进行判断,再根据对各个条件的选择进行进一步的编写,将本程序分成不同的小模块

    (4)

  • 相关阅读:
    Python
    保护模式(九):挂物理页
    保护模式(八):MmIsAddressValid逆向(PAE)
    保护模式(七):2-9-9-12分页
    保护模式(六):10-10-12分页(二)
    保护模式(五):10-10-12分页(一)
    保护模式(四):任务段与任务门
    保护模式(三):中断门与陷阱门
    保护模式(二):调用门
    保护模式(一):段描述符与段选择子
  • 原文地址:https://www.cnblogs.com/1305yyf/p/4348514.html
Copyright © 2011-2022 走看看