1. 0 2 8 3 0 2. public class Question2 { public static int gap(int[] a) { int max = 0; for (int i = 0; i < a.length-1; i++) { int d = a[i+1]-a[i]; if (d > max) max = d; } return max; } public static void main(String[] args) { int[] a = new int[args.length]; for (int i = 0; i < a.length; i++) { a[i] = Integer.parseInt(args[i]); } System.out.println(gap(a)); } } 3. import java.util.*; public class DominoModel { private List set; public DominoModel() { set = new ArrayList(); for (int i = 0; i <= 6; i++) { for (int j = i; j <= 6; j++) { set.add(new DominoTile(i,j)); } } System.out.println(set.size()); } public DominoTile pickTile() { if (set.size() == 0) return null; int i = (int) (Math.random()*set.size()); return set.remove(i); } public boolean match(DominoTile tile1, DominoTile tile2) { return (tile1.getLeft() == tile2.getLeft() || tile1.getLeft() == tile2.getRight() || tile1.getRight() == tile2.getLeft() || tile1.getRight() == tile2.getRight()); } } 4. public static int[][] shift(int n) { int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = (i+j) % n; } } return a; } 5. public static boolean login(String userName, String password) { try { Scanner scanner = new Scanner(new File("accounts.txt")); while (scanner.hasNext()) { String userName1 = scanner.next(); String password1 = scanner.next(); if (userName1.equals(userName) && password1.equals(password)) return true; } return false; } catch (FileNotFoundException e) { return false; } }