zoukankan      html  css  js  c++  java
  • 二柱子之随机四则运算

    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 }
  • 相关阅读:
    ES vm报错
    ln -s /usr/local/jdk1.8.0_201/bin/java /bin/java
    docker压缩导入导出
    微软各种资源整理(迅雷下载),感谢站长。
    python打开文件的访问方式
    docker换源
    selinux
    ElasticsearchException: java.io.IOException: failed to read [id:0, file:/data/elasticsearch/nodes/0/_state/global-0.st]
    带了纸和笔,要记哪些东西?
    redis命令行批量删除匹配到的key
  • 原文地址:https://www.cnblogs.com/L-Damon-v/p/5242995.html
Copyright © 2011-2022 走看看