• 随机产生30个两位数的四则运算(包括真分数的计算)


    //3.3.2016 tangyeye
    #include<stdio.h>
    #include<iostream>
    #include<time.h>
    using namespace std;
    #define MAX 100
    
    int main(int argc,char*argv[])
    {   
        int a,b,c,d,e;
        
    srand((unsigned)time(NULL));
    for(int i=0;i<30;i++)
       {
        a=rand()%MAX;
        b=rand()%MAX;
        d=rand()%MAX;
        e=rand()%MAX;
        
        c=rand()%12+1;
    
        if(d<e&&e!=0)
        {
        switch(c)
           {
            case 1: cout<<a<<"+"<<b<<endl;
            break;
    
            case 2: cout<<a<<"-"<<b<<endl;
            break;
    
            case 3: cout<<a<<"*"<<b<<endl;
            break;
    
            case 4: cout<<a<<"/"<<b<<endl;
            break;
    
            case 5: cout<<d<<"/"<<e<<"+"<<b<<endl;
            break;
    
            case 6: cout<<a<<"+"<<d<<"/"<<e<<endl;
            break;
            
            case 7: cout<<d<<"/"<<e<<"-"<<b<<endl;
            break;
    
            case 8: cout<<a<<"-"<<d<<"/"<<e<<endl;
            break;
    
            case 9: cout<<d<<"/"<<e<<" "<<"*"<<b<<endl;
            break;
    
            case 10: cout<<a<<"*"<<" "<<d<<"/"<<e<<endl;
            break;
    
            case 11: cout<<d<<"/"<<e<<" "<<"/"<<b<<endl;
            break;
    
            case 12: cout<<a<<"/"<<" "<<d<<"/"<<e<<endl;
            break;
    
           }
        
        }
        else
            
            switch(c)
           {
            case 1: cout<<a<<"+"<<b<<endl;
            break;
    
            case 2: cout<<a<<"-"<<b<<endl;
            break;
    
            case 3: cout<<a<<"*"<<b<<endl;
            break;
    
            case 4: cout<<a<<"/"<<b<<endl;
            break;
    
            case 5: cout<<e<<"/"<<d<<"+"<<b<<endl;
            break;
    
            case 6: cout<<a<<"+"<<e<<"/"<<d<<endl;
            break;
            
            case 7: cout<<e<<"/"<<d<<"-"<<b<<endl;
            break;
    
            case 8: cout<<a<<"-"<<e<<"/"<<d<<endl;
            break;
    
            case 9: cout<<e<<"/"<<d<<" "<<"*"<<b<<endl;
            break;
    
            case 10: cout<<a<<"*"<<" "<<e<<"/"<<d<<endl;
            break;
    
            case 11: cout<<e<<"/"<<d<<" "<<"/"<<b<<endl;
            break;
    
            case 12: cout<<a<<"/"<<" "<<e<<"/"<<d<<endl;
            break;
    
            }
       
    }
     return 0;
    
    }
  • 相关阅读:
    jetnuke v1.2安装
    Java Gaming Resources
    @MyEclipse启动Tomcat时Console不显示(已解决+配图)
    在JXSE中,DHT=SRDI
    LINQ 学习笔记9 Kevin
    LINQ 学习笔记6 Kevin
    C# 中自定义事件 Kevin
    LINQ 学习笔记7 Kevin
    C#调用浏览器(默认和非默认浏览器) Kevin
    Section1 Agile Development Kevin
  • 原文地址:https://www.cnblogs.com/tyyhph/p/5242026.html
Copyright © 2020-2023  润新知