Go to diff to previous submission
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * * @author student */ public class Mosquito { /** * @param args the command line arguments */ List<Integer> result = new ArrayList<Integer>(); int[] a = new int[7]; int pom = 0; while (!"".equals(res)) { for (int i = 0; i < ress.length; i++) { } try { if (a[6] > 0) { for (int i = 0; i < a[6]; i++) { pom = a[0]; if (a[5] > 0) { } else { a[0] = a[1]; } if (a[4] > 0) { } else { a[1] = a[2]; } a[2] = pom * a[3]; } } } result.add(a[0]); res = sc.nextLine(); } } } }
--- c4.s862.cteam124.mosquito.java.0.Mosquito.java +++ c4.s1000.cteam124.mosquito.java.0.Mosquitko.java @@ -1,9 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package mosquito; - -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import java.util.Scanner; @@ -21,5 +15,5 @@ Scanner sc = new Scanner(System.in); String res = sc.nextLine(); - List<Integer> result = new LinkedList<Integer>(); + List<Integer> result = new ArrayList<Integer>(); int[] a = new int[7]; int pom = 0; @@ -29,20 +23,24 @@ a[i] = Integer.parseInt(ress[i]); } - if (a[6] > 0) { - for (int i = 0; i < a[6]; i++) { - pom = a[0]; - if (a[5] > 0) { - a[0] = Math.round(a[1] / a[5]); - } else { - a[0] = a[1]; - } - if (a[4] > 0) { - a[1] = Math.round(a[2] / a[4]); - } else { - a[1] = a[2]; - } - a[2] = pom * a[3]; + try { + if (a[6] > 0) { + for (int i = 0; i < a[6]; i++) { + pom = a[0]; + if (a[5] > 0) { + a[0] = Math.round(a[1] / a[5]); + } else { + a[0] = a[1]; + } + if (a[4] > 0) { + a[1] = Math.round(a[2] / a[4]); + } else { + a[1] = a[2]; + } + a[2] = pom * a[3]; + } } + } catch(ArithmeticException ex) { + System.err.println(ex.toString()); } result.add(a[0]); @@ -55,3 +53,3 @@ } -} +} \ No newline at end of file