date: 2018/1/18 14:39:47
2018年JAVA基础节课考试—本人错误集合
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| package android.xiaolan.paixu.tools; import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int a, b, c, max, mix; public static void main(String[] args) { Run1(); Run2(); Run3(); } private static void Run3() { System.out.println("第一个数"); a = sc.nextInt(); System.out.println("第二个数"); b = sc.nextInt(); System.out.println("第三个数"); c = sc.nextInt(); if (a > b) { max = a; } else { max = b; } if (max > c) { } else { max = c; } if (a < b) { mix = a; } else { mix = b; } if (mix < c) { } else { mix = c; } System.out.println(mix); if (max == a) { if (b > c) { System.out.println(b); } else { System.out.println(c); } } if (max == b) { if (a > c) { System.out.println(a); } else { System.out.println(c); } } if (max == c) { if (a > b) { System.out.println(a); } else { System.out.println(b); } } System.out.println(max); } private static void Run2() { System.out.println("第一个数"); a = sc.nextInt(); System.out.println("第二个数"); b = sc.nextInt(); System.out.println("第三个数"); c = sc.nextInt(); for (int i = 0; i < 2; i++) { if (a > b) { int max = a; a = b; b = max; } if (b > c) { int max = b; b = c; c = max; } } System.out.println(a + "\n" + b + "\n" + c); } private static void Run1() { int a[] = new int[3]; for (int i = 0; i < a.length; i++) { System.out.println("输入第" + (i + 1) + "个数"); a[i] = sc.nextInt(); } Arrays.sort(a); for (int i = 0; i < a.length; i++) { System.out.println(a[i]); } } }
|