9.16java summary

Enumeration EnunTest.java

operation result

false
false
true
SMALL
MEDIUM
LARGE

== enumerated type can be directly used to determine whether the same, which represents a data string, there are a number of attributes. It is a reference type.

Lack of precision floating-point computations

Because decimal fractions there may exist an infinite number of decimal to binary conversion as 0.9 when converted to a binary fraction in 11100100100100.....

Can not eliminate fractional part, it would exceed the double-byte space

Use java.math.BigDecimal. Precise operation

Classroom tests

Ideas for setting the number of loop

else if statements to distinguish four operations, the multiplication result of the while loop process is a decimal division divisible

Each array record number and the symbol, to produce formula, re-check, the cycle is repeated until no

Source Code

// Letter 1805-2 20,183,509 Zhang Yunfei

package jishu;
import java.util.Random;
import java.util.Scanner;
public class size {
static Scanner input=new Scanner(System.in);
static int num;
static String []str=new String[4];
public static void main(String[]args) {
int []a=new int[10000000];
int []b=new int[10000000];
int []c=new int[10000000];
System.out.print("请输入一共输入多少个");
int x;
num=input.nextInt();
System.out.println("一行个数");
x=input.nextInt();
str[0]="+";
str[1]="-";
str[2]="*";
str[3]="/";
Random rand=new Random();
int num1,num2,num3;
int num0=0;
for(int i=0;i<Surely; i ++) {
int z=0;
do{
z=0;
num1=rand.nextInt(99)+1;
num2=rand.nextInt(4);
if(num2==1)
num3=rand.nextInt(num1);
else if(num2==2) {
int xnn=100/num1;
num3=rand.nextInt(xnn)+1;
}
else if(num2==3) {
num3=rand.nextInt(num1)+1;
boolean tf=true;
while(tf){
if(num1%num3==0)tf=false;
else
num3=rand.nextInt(num1)+1;
}
}
else
num3=rand.nextInt(98)+1;
if(num0==0) {
a[0]=num1;
b[0]=num2;
c[0]=num3;
num0=1;
}
for(int j=1;j<num0;j++) {
if((num1==a[j])&&(num2==b[j])&&(num3==c[j])) {
z=0;
}
else {
z=1;
a[j]=num1;
b[j]=num2;
c[j]=num3;
num0++;
}
}
}while(z==1);
System.out.print(i+1);
System.out.print("、");
System.out.print(num1);
System.out.print(str[num2]);
System.out.print(num3);
System.out.print("=");
if((i+1)%x==0)
System.out.println(" ");
else
System.out.print(" ");

}

}

}

Guess you like

Origin www.cnblogs.com/huiwuyan20/p/11543594.html