1 import java.util.HashSet; 2 import java.util.Random; 3 import java.util.ArrayList; 4 import java.util.Arrays; 5 import java.util.Scanner; 6 7 8 public class siziyunsuan { 9 10 11 public static void main(String[] args) { 12 Random random = new Random(); 13 14 //定制数量 15 int x; 16 System.out.println("输入制定个数"); 17 Scanner sc = new Scanner(System.in); 18 x = sc.nextInt(); 19 20 //打印多少 21 int ans; 22 System.out.println("请输入想打印多少"); 23 ans = sc.nextInt(); 24 25 //最大值 26 int len; 27 System.out.println("请输入最大值范围"); 28 len = sc.nextInt(); 29 int random1; 30 31 int j = 0; 32 33 //System.out.println(chark); 34 while (j <= ans) { 35 int houhou = 0; 36 for (int i = 0; i < (2 * x )- 1; i++) { 37 int p = random.nextInt(2*x-1); 38 if(i%2==0&&p==i&&p!=2*x-2) 39 { 40 houhou++; 41 System.out.print("("); 42 } 43 44 if (i % 2 == 0) { 45 System.out.print(random.nextInt(len) + 1); 46 47 } 48 else { 49 switch (random.nextInt(4)) { 50 case 0: 51 System.out.print("+"); 52 break; 53 case 1: 54 System.out.print("-"); 55 break; 56 case 2: 57 System.out.print("*"); 58 break; 59 case 3: 60 System.out.print("/"); 61 break; 62 } 63 } 64 65 66 67 } 68 if(houhou == 1) 69 System.out.print(")"); 70 j++; 71 System.out.println(); 72 73 } 74 75 76 } 77 }