• 结队开发-四则运算


    在网上搜索有所借鉴

    package team1;
    import java.lang.Math;
    import java.util.Random;
    import java.util.Scanner;
    public class Check {
     public static int a=new Random().nextInt(100);
     public static int b[][]=new int[100][2];
     public static int c[]=new int[100];
     static Scanner d=null;
        public static void main(String[] args) {
         int oneNum = (int)(1 + Math.random()*99);
            int twoNum = 1 + (int)(Math.random()*99);
            int thrNum = 1 + (int)(Math.random()*4);
            d =new Scanner(System.in);
            System.out.println("请输入题目总数量:");
            int n=d.nextInt();
            System.out.println("请输入一行的题目数量:");
            
         for(int i = 1;i <=n;i++)
            {
       b[i][0]=oneNum;
          b[i][1]=thrNum;
          c[i]=twoNum;
          for(int j=0;j<i;j++)
          {
           if(b[j][0]==oneNum&&b[j][1]==thrNum&&c[j]==twoNum)
           {
            a=new Random().nextInt(100);
           }
          }
          System.out.println(i);
                if(thrNum == 1)
                {
                    System.out.println(oneNum + "+" + twoNum + "=");
                }
                if(thrNum == 2)
                {
                 if(oneNum>=twoNum)
                    {System.out.println(oneNum + "-" + twoNum + "=");}
                 else
                 {
                  int T;
                  T=twoNum;
                  twoNum=oneNum;
                  oneNum=T;
                  System.out.println(oneNum + "-" + twoNum + "=");
                 }
                }
                if(thrNum == 3)
                {
                 int A=oneNum *twoNum;
                 if(A>100)
                 { a=new Random().nextInt(100);
                    System.out.println(oneNum + "*" + twoNum +"=");
                 }
                 else 
                  System.out.println(oneNum + "*" + twoNum +"=");
                }
                if(thrNum == 4)
                {
                 int B=oneNum%twoNum;
                 if(B!=0&&twoNum==0)
                 {
                  a=new Random().nextInt(100);
                   System.out.println(oneNum + "/" + twoNum + "=");
                 }
                 else{
                   if(twoNum != 0)
                         {
                             System.out.println(oneNum + "/" + twoNum  + "=");
                         }
                         else if(oneNum != 0)
                         {
                             System.out.println(oneNum + "/" + twoNum + "=");
                         }
                         else
                         {
                             System.out.println(30 + "/" + 15 + "=?");
                         }
                 }
                   
                }
            }
        }
    }
  • 相关阅读:
    Tomcat详解系列(3)
    Tomcat详解系列(2)
    Tomcat详解系列(1)
    常用开发库
    单元测试
    [MongoDB知识体系] 一文全面总结MongoDB知识体系
    问题记录:net::ERR_CERT_AUTHORITY_INVALID
    CSS+DIV特色开关按钮
    Jquery的Ajax简易优化思路
    CSS+DIV简易灯泡案例
  • 原文地址:https://www.cnblogs.com/123-haozijia/p/13031787.html
Copyright © 2020-2023  润新知