Go to diff to previous submission
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package mosquito; import java.util.Scanner; /** * * @author student */ public class Mosquito { /** * @param args the command line arguments */ int[] a = new int[7]; int pom = 0; while (sc.hasNextInt()) { a[0] = sc.nextInt(); a[1] = sc.nextInt(); a[2] = sc.nextInt(); a[3] = sc.nextInt(); a[4] = sc.nextInt(); a[5] = sc.nextInt(); a[6] = sc.nextInt(); 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]; } } } } }
--- c4.s1002.cteam124.mosquito.java.0.Mosquito.java +++ c4.s1018.cteam124.mosquito.java.0.Mosquito.java @@ -1,4 +1,8 @@ -import java.util.ArrayList; -import java.util.List; +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package mosquito; + import java.util.Scanner; @@ -12,16 +16,18 @@ * @param args the command line arguments */ - public static void main(String[] args) { + public static void main(String[] args)throws Exception { Scanner sc = new Scanner(System.in); - String res = sc.nextLine(); - List<Integer> result = new ArrayList<Integer>(); int[] a = new int[7]; int pom = 0; - while (!"".equals(res)) { - String[] ress = res.split(" "); - for (int i = 0; i < ress.length; i++) { - a[i] = Integer.parseInt(ress[i]); - } - try { + + while (sc.hasNextInt()) { + a[0] = sc.nextInt(); + a[1] = sc.nextInt(); + a[2] = sc.nextInt(); + a[3] = sc.nextInt(); + a[4] = sc.nextInt(); + a[5] = sc.nextInt(); + a[6] = sc.nextInt(); + if (a[6] > 0) { for (int i = 0; i < a[6]; i++) { @@ -41,15 +47,9 @@ } } - } catch(ArithmeticException ex) { - System.err.println(ex.toString()); + + System.out.println(a[0]); } - result.add(a[0]); - res = sc.nextLine(); - } - for (Integer string : result) { - System.out.println(string); - } } -} \ No newline at end of file +}