zoukankan      html  css  js  c++  java
  • 2019年9月16日课堂随机出题

     (1)源代码

    import java.util.*;
    public class FourFundamental {
        public static void main(String[] args) {
            
            int i;
            Random R = new Random();
            
            for(i=0;i<30;i++) {
                switch(R.nextInt(4)+1) {
                case 1:
                    jia();
                    break;
                case 2:
                    jian();
                    break;
                case 3:
                    cheng();
                    break;
                case 4:
                    chu();
                    break;
                }
                
                
            }
            
            
    
    
    
        }
        public static void jia() {
            Random T = new Random();
            Random R = new Random();
            System.out.println(T.nextInt(101)+" + "+R.nextInt(101)+" = ");
        }
        public static void jian() {
            Random T = new Random();
            Random R = new Random();
            System.out.println(T.nextInt(101)+" - "+R.nextInt(101)+" = ");
        }
        public static void cheng() {
            Random T = new Random();
            Random R = new Random();
            System.out.println(T.nextInt(101)+" * "+R.nextInt(101)+" = ");
        }
        public static void chu() {
            Random T = new Random();
            Random R = new Random();
            System.out.println(T.nextInt(101)+" / "+R.nextInt(101)+" = ");
        }
    }
    FourFundamental

    (2)输出结果

  • 相关阅读:
    ADO.NET存取数据库数据
    2017-01-03
    re模块
    random模块(随机)
    sys模块
    os模块
    datetime模块
    time模块
    logging模块
    Python函数初识
  • 原文地址:https://www.cnblogs.com/suanai/p/11587519.html
Copyright © 2011-2022 走看看