• 软件工程个人作业01


    源代码://四则运算
    //邵文正 20142894  2016.3.7
    #include<iostream>
    using namespace std;
    int random()
         {
            return(rand()%100);
         }
    char Fuhao()
         {
            int a;
           a = rand() % 4;
           if (a == 1)
        {
              return '+';
        }
         if (a == 2)
        {
              return '-';
        }
        if (a == 3)
        {
            return'*';
        }
        else
        {
            return'/';
        }
    }
    void Jiafenshu()
    {
          int x, y;
          m:y = rand() % 10;
        if (y == 0)
        {
              goto m;
        }
        x = rand() % 100;
        cout <<"("<< x << "/" << y<<")" ;
    }
    void main()
    {
          int a, b;
        
          cout << "以下是30个四则运算不包含假分数 " << endl;
          for (int i = 0; i < 30; i++)
        {
              x:a = random();
              b = random();
              Fuhao();
              if (Fuhao() == '/' || b == 0)
            {
                  goto x;
            }
                 cout << a << Fuhao() << b << "=   " << endl;
        }
           cout << "以下是假分数的运算30个: " << endl;
        for (int i = 0; i < 30; i++)
        {
            Jiafenshu();
            cout << Fuhao();
            Jiafenshu();
            cout <<"=  "<< endl;
        }
          
    }

    程序运行结果截图:

  • 相关阅读:
    ajax java base64 图片储存
    计算瓶酒的数量
    Eclipse 打不开
    C# 调用百度翻译Api
    MVC API 权限控制
    C#编程语言与面向对象——委托
    C#编程语言与面向对象—— 多态
    C#编程语言与面向对象——抽象基类与接口
    C#编程语言与面向对象——继承
    动态加载及调用程序集
  • 原文地址:https://www.cnblogs.com/aishangtaxuefeihong/p/5252054.html
Copyright © 2020-2023  润新知