zoukankan      html  css  js  c++  java
  • 2020.10.01

    一、今日学习内容

       对上节课的Java测试的题目进行完善

       随机输出30道题目,且不重复

     1 package yunsuan;
     2 import java.util.Scanner;
     3 public class Sizeyunsuan {
     4     
     5     public static void main(String[] args) {
     6         Scanner con=new Scanner(System.in);
     7         int d,N;
     8         System.out.println("请输入题目数量:");
     9         N=con.nextInt();
    10         int[] a=new int[N];
    11         int[] b=new int[N];
    12         int[] c=new int[N];
    13         for(int i=0;i<N;i++) {
    14           int f=0;
    15           a[i]=(int)(Math.random()*100+1);
    16           b[i]=(int)(Math.random()*100+1);
    17           c[i]=(int)(Math.random()*4+1);
    18           for(int j=0;j<i;j++) {
    19               if(a[i]==a[j]&&b[i]==b[j]&&c[i]==c[j])
    20                   f=1;
    21           }
    22           if(f==1)continue;
    23           switch(c[i]) {
    24           case 1:{
    25               System.out.println("("+(i+1)+")"+a[i]+"+"+b[i]+"=");
    26               d=con.nextInt();
    27               break;
    28           }
    29           case 2:{
    30               System.out.println("("+(i+1)+")"+a[i]+"-"+b[i]+"=");
    31               d=con.nextInt();
    32               break;
    33           }
    34           case 3:{
    35               System.out.println("("+(i+1)+")"+a[i]+"*"+b[i]+"=");
    36               d=con.nextInt();
    37               break;
    38           }
    39           case 4:{
    40               System.out.println("("+(i+1)+")"+a[i]+"/"+b[i]+"=");
    41               d=con.nextInt();
    42               break;
    43           }
    44           }
    45         }
    46 
    47     }
    48 
    49 }

    二、遇到的问题

        只实现了第一、二个功能,对第三个功能还没有实现(对乘除、括号、操作数的要求)。

    三、明日计划

       继续对老师发的源代码进行运行验证。

  • 相关阅读:
    第八章 多线程编程
    Linked List Cycle II
    Swap Nodes in Pairs
    Container With Most Water
    Best Time to Buy and Sell Stock III
    Best Time to Buy and Sell Stock II
    Linked List Cycle
    4Sum
    3Sum
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/wmdww/p/13758920.html
Copyright © 2011-2022 走看看