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.LinkedList; import java.util.List; import java.util.Scanner; /** * * @author student */ public class Mosquito { /** * @param args the command line arguments */ List<Integer> result = new LinkedList<Integer>(); int[] a = new int[7]; int pom = 0; while (!"".equals(res)) { for (int i = 0; i < ress.length; i++) { } 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.s856.cteam124.mosquito.java.0.Mosquito.java +++ c4.s862.cteam124.mosquito.java.0.Mosquito.java @@ -22,27 +22,35 @@ String res = sc.nextLine(); List<Integer> result = new LinkedList<Integer>(); - int[] a = new int[7]; + 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]); - } - 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]; - + while (!"".equals(res)) { + String[] ress = res.split(" "); + for (int i = 0; i < ress.length; i++) { + 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]; + + } + } + result.add(a[0]); + res = sc.nextLine(); } - result.add(a[0]); - res = sc.nextLine(); - } for (Integer string : result) { System.out.println(string); } - + }