星期五進行了某科的某次測驗..
而比較重要的題目在回家後也都試了一次,記錄如下
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
| import java.util.ArrayList; import java.util.Collections;
class IPTest {
public static void main(String[] args) { printStart(); System.out.println(); printRangeA(); System.out.println("\n"); printRangeB(); }
public static void printStart() { int i, j, n=5; for(i=n; i>=1; i--) { for(j=n; j>=1; j--) { if (i < j) { System.out.print("*"); }else{ System.out.print(""+j); } } System.out.println(); } }
public static ArrayList<Integer> tempA = new ArrayList<Integer>(); public static void printRangeA() { for(int i = 0; i<50; i++) { int x = (int)(Math.random()*5)*5; if (!tempB.contains(x)) tempB.add(x); if (tempB.size() >= 5) break; }
Collections.sort(tempB); System.out.print(tempB); }
public static ArrayList<Integer> tempB = new ArrayList<Integer>(); public static void printRangeB() { for(int i = 0; i<50; i++) { int x = (int)(Math.random()*8+5)*5; if (!tempB.contains(x)) tempB.add(x); if (tempB.size() >= 8) break; } Collections.sort(tempB); System.out.print(tempB); }
}
|