public class Exercise7 { public static void main(String[] args) { // test calls here } public static int minimumPosition(int[] a) { int m = 0; int n = a.length; for (int i = 1; i < n; i++) { if (a[i] < a[m]) m = i; } return m; } public static int minimumElement1(int[] a) { int p = minimumPosition(a); return a[p]; } public static int minimumElement2(int[] a) { int m = 0; int n = a.length; for (int i = 1; i < n; i++) { if (a[i] < m) m = a[i]; } return m; } public static int[] append(int[] a, int[] b) { int n = a.length; int m = b.length; int[] c = new int[n+m]; for (int i=0; i Integer.MAX_VALUE-b[i]) overflow = i; else a[i] += b[i]; } return overflow; } public static class OverflowException extends Exception { public final int pos; /*@ public normal_behavior @ requires true; @ ensures this.pos == pos; @*/ public OverflowException(int pos) { this.pos = pos; } } public static void add2(int[] a, int[] b) throws OverflowException { int n = a.length; boolean okay = true; for (int i = 0; i < n; i++) { if (a[i] > Integer.MAX_VALUE-b[i]) throw new OverflowException(i); else a[i] += b[i]; } } }