• 课堂测试


    课堂测试1:

    import java.util.Random;
    public class Sapp {
     public static void main(String[] args) {
      Random ran=new Random();
      for(int i=1;i<31;i++) {
       int a=ran.nextInt(100);
       int b=ran.nextInt(100);
       int c=ran.nextInt(4);
       if(c==0)
       {
        System.out.print(i+".");
        System.out.println(a+"+"+b+"=");
       }
       else if(c==1&&a>=b)
       {
        System.out.print(i+".");
        System.out.println(a+"-"+b+"=");
       }
       else if(c==2&&a*b<100)
       {
        System.out.print(i+".");
        System.out.println(a+"*"+b+"=");
       }
       else if(c==3&&b!=0&&a%b==0)
       {
        System.out.print(i+".");
        System.out.println(a+"/"+b+"=");
       }
       else
       {
        i--;
       }
      }
     }
    }
    课堂测试2:
    import java.util.Scanner;
    import java.util.Random;
    public class Sappp {
     static Scanner scan = new Scanner(System.in);
     public static void main(String[] args) {
      System.out.println("请输入题目数量:");
      int n = scan.nextInt();
      System.out.println("请输入每行题目个数:");
      int m = scan.nextInt();
      int[][] s1=new int[n/3+1][m];
      int[][] s2=new int[n/3+1][m];
      int[][] s3=new int[n/3+1][m];
      Random ran = new Random();
      for (int i = 1; i < (n / m)+2; i++) {
       for (int l = 1; l < m+1; l++) {
        int a = ran.nextInt(100);
        int b = ran.nextInt(100);
        int c = ran.nextInt(4);
        int k=l+(i-1)*m;
        if(k>n||(s1[i-1][l-1]==a&&s2[i-1][l-1]==b&&s3[i-1][l-1]==c))
         break;
        if (c == 0) {
         System.out.print(k+ ".");
         System.out.print(a + "+" + b + "=    ");
         s1[i-1][l-1]=a;
         s2[i-1][l-1]=b;
         s3[i-1][l-1]=c;
        } else if (c == 1 && a >= b) {
         System.out.print(k + ".");
         System.out.print(a + "-" + b + "=    ");
         s1[i-1][l-1]=a;
         s2[i-1][l-1]=b;
         s3[i-1][l-1]=c;
        } else if (c == 2 && a * b < 100) {
         System.out.print(k + ".");
         System.out.print(a + "*" + b + "=    ");
         s1[i-1][l-1]=a;
         s2[i-1][l-1]=b;
         s3[i-1][l-1]=c;
        } else if (c == 3 && b != 0 && a % b == 0) {
         System.out.print(k + ".");
         System.out.print(a + "/" + b + "=    ");
         s1[i-1][l-1]=a;
         s2[i-1][l-1]=b;
         s3[i-1][l-1]=c;
        } else {
         l--;
        }
       }
       System.out.println("");
      }
     }
    }
  • 相关阅读:
    500内部服务器错误
    silverlight中实现页面传值
    每个程序员必备的10种工具
    ora-12514:TNS:listener does not currently know of service requested in connect descriptor
    利用VBA 宏实现vc6.0的自动添加注释和自动取消注释
    plsql developer (在8.04版本中试过可用)
    修改Oracle数据库字符集
    80端口被占用(端口检查)解决
    sql server分页
    解决问题 “You don't have permission to access /index.html on this server.”
  • 原文地址:https://www.cnblogs.com/dd110343/p/11552604.html
Copyright © 2020-2023  润新知