随机产生300道四则运算

 

随机产生的四则运算(java)

import java.util.Random;

public class QQ {

public static void main(String[] args) {

String[] operate=new String[]{"+","-","×","÷"};
int[] numbers=new int[1000];

for(int i=1;i<=1000;i++){
numbers[i-1]=i;
}
Random r=new Random();//随机数

for(int i=0;i<300;i++){

System.out.println(numbers[r.nextInt(1000)]+operate[r.nextInt(4)]+numbers[r.nextInt(1000)]+"=");
}
}
}

 

import java.util.Random;

public class QQ {

public static void main(String[] args) {

String[] operate=new String[]{"+","-","×","÷"};
int[] numbers=new int[1000];

for(int i=1;i<=1000;i++){
numbers[i-1]=i;
}
Random r=new Random();

for(int i=0;i<300;i++){

System.out.println(numbers[r.nextInt(1000)]+operate[r.nextInt(4)]+numbers[r.nextInt(1000)]+"=");
}
}
}

1

 

 

posted @ 2017-03-11 21:25  张佳慧1502720137  阅读(157)  评论(0编辑  收藏  举报