• 二柱子之随机四则运算


    1.  1 //      2016/3/3   
       2 //1.随机生成10以内的数为 a
       3 //2.以0代表'+',1代表'-',2代表'*',3代表'/' 随机生成4以内的数为 运算符
       4 //3.随机生成100以内的数为 b
       5 //4. a 运算符 b =
       6 //1.随机生成10以内的数 a
       7 //2.随机生成10以内的数 b
       8 //3.随机生成10以内的数 c
       9 //4.随机生成10以内的数 d
      10 //5.如果b不大于a 重复1 2  第一个真分数是a/b  第二个真分数是c/d
      11 //6.以1代表'+',2代表'-',3代表'*',4代表'/' 随机生成4以内的数为 运算符
      12 //7.a/b 运算符 c/d =
      13 #include<iostream>
      14 #include<ctime>
      15 using namespace std;
      16 int main()
      17 {
      18     srand((unsigned)time(0)); 
      19     int i=0;
      20     while(i<30)
      21     {
      22         int a=rand()%10;
      23         int b=rand()%10;
      24         int c=rand()%4;
      25         if(0==c) 
      26         {
      27             cout<<i+1<<". "<<a<<"+"<<b<<"="<<endl;
      28             i++;
      29         }
      30         if(1==c) 
      31         {
      32             cout<<i+1<<". "<<a<<"-"<<b<<"="<<endl;
      33             i++;
      34         }
      35         if(2==c)
      36         {
      37             cout<<i+1<<". "<<a<<"*"<<b<<"="<<endl;
      38             i++;
      39         }
      40         if(3==c&&0!=b)
      41         {
      42             cout<<i+1<<". "<<a<<"/"<<b<<"="<<endl;
      43             i++;
      44         }
      45     }
      46     int j=0;
      47     while(j<30)
      48     {
      49         int a=rand()%10;
      50         int b=rand()%10;
      51         if(a<=b&&b!=0)
      52         {
      53             int c=rand()%10;
      54             int d=rand()%10;
      55             if(c<=d&&d!=0)
      56             {
      57                 int e=rand()%4;
      58                 if(0==e) 
      59                 {
      60                     cout<<j+1<<". "<<a<<"/"<<b<<" + "<<c<<"/"<<d<<"="<<endl;
      61                     j++;
      62                 }
      63                 if(1==e)
      64                 {
      65                     cout<<j+1<<". "<<a<<"/"<<b<<" - "<<c<<"/"<<d<<"="<<endl;
      66                     j++;
      67                 }
      68                 if(2==e)
      69                 {
      70                     cout<<j+1<<". "<<a<<"/"<<b<<" * "<<c<<"/"<<d<<"="<<endl;
      71                     j++;
      72                 }
      73                 if(3==e&&0!=a)
      74                 {
      75                     cout<<j+1<<". "<<a<<"/"<<b<<" / "<<c<<"/"<<d<<"="<<endl;
      76                     j++;
      77                 }
      78             }
      79         }
      80     }
      81 }
  • 相关阅读:
    1234D.Distinct Characters Queries(树状数组)
    1217C.The Number of Good Substrings(思维)
    1217B.Zmei Gorynich(思维)
    1213D2.Equalizing by Division(hard version)(图论)
    CentOS7.5搭建Hadoop2.7.6完全分布式集群
    CentOS7.5搭建spark2.3.1集群
    CentOS7.5搭建Hive2.3.3
    【Java入门】JDK安装和环境变量配置(Win7版)
    python第三方库大全
    Python常用模块大全
  • 原文地址:https://www.cnblogs.com/L-Damon-v/p/5242995.html
Copyright © 2020-2023  润新知