public class JAVA17_3 { public static String formatFloatNumber(Double value) { if(value != null){ if(value.doubleValue() != 0.00){ java.text.DecimalFormat df = new java.text.DecimalFormat("########.00"); return df.format(value.doubleValue()); }else{ return "0.00"; } } return ""; } public static void main(String[] args) { // TODO Auto-generated method stub double[][] allNum = new double[30][30]; String string = " 7 Z" + " 5 8 Z" + " 7 8 8 Z" + " 9 2 7 2 Z" + " 8 1 4 9 1 Z" + " 8 1 8 8 4 1 Z" + " 7 9 6 1 4 5 4 Z" + " 5 6 5 5 6 9 5 6 Z" + " 5 5 4 7 9 3 5 5 1 Z" + " 7 5 7 9 7 4 7 3 3 1 Z" + " 4 6 4 5 5 8 8 3 2 4 3 Z" + " 1 1 3 3 1 6 6 5 5 4 4 2 Z" + " 9 9 9 2 1 9 1 9 2 9 5 7 9 Z" + " 4 3 3 7 7 9 3 6 1 3 8 8 3 7 Z" + " 3 6 8 1 5 3 9 5 8 3 8 1 8 3 3 Z" + " 8 3 2 3 3 5 5 8 5 4 2 8 6 7 6 9 Z" + " 8 1 8 1 8 4 6 2 2 1 7 9 4 2 3 3 4 Z" + " 2 8 4 2 2 9 9 2 8 3 4 9 6 3 9 4 6 9 Z" + " 7 9 7 4 9 7 6 6 2 8 9 4 1 8 1 7 2 1 6 Z" + " 9 2 8 6 4 2 7 9 5 4 1 2 5 1 7 3 9 8 3 3 Z" + " 5 2 1 6 7 9 3 2 8 9 5 5 6 6 6 2 1 8 7 9 9 Z" + " 6 7 1 8 8 7 5 3 6 5 4 7 3 4 6 7 8 1 3 2 7 4 Z" + " 2 2 6 3 5 3 4 9 2 4 5 7 6 6 3 2 7 2 4 8 5 5 4 Z" + " 7 4 4 5 8 3 3 8 1 8 6 3 2 1 6 2 6 4 6 3 8 2 9 6 Z" + " 1 2 4 1 3 3 5 3 4 9 6 3 8 6 5 9 1 5 3 2 6 8 8 5 3 Z" + " 2 2 7 9 3 3 2 8 6 9 8 4 4 9 5 8 2 6 3 4 8 4 9 3 8 8 Z" + " 7 7 7 9 7 5 2 7 9 2 5 1 9 2 6 5 3 9 3 5 7 3 5 4 2 8 9 Z" + " 7 7 6 6 8 7 5 5 8 2 4 7 7 4 7 2 6 9 2 1 8 2 9 8 5 7 3 6 Z" + " 5 9 4 5 5 7 5 5 6 3 5 3 9 5 8 9 5 4 1 2 6 1 4 3 5 3 2 4 1 Z" + "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X "; int tag1 = 0; int tag2 = 0; for(int i = 0; i < string.length(); i++) { if(string.charAt(i) > ‘0‘ && string.charAt(i) <= ‘9‘) { allNum[tag1][tag2] = Integer.parseInt(string.charAt(i)+""); tag2++; } if(string.charAt(i)==‘Z‘) { tag1++; tag2=0; } } double halfPower=0; for(int i = 1; i < 29; i++) { for(int j = 1; j <= i; j++) { halfPower = allNum[i-1][j-1]/2.0; allNum[i][j-1]+=halfPower; allNum[i][j] += halfPower; } } double MIN = Double.MAX_VALUE; double MAX = Double.MIN_VALUE; for(int i = 0; i < 29; i++) { if (allNum[28][i]>MAX) { MAX = allNum[28][i]; } if (allNum[28][i]<MIN) { MIN = allNum[28][i]; } } System.out.print(formatFloatNumber(2086458231*MAX/MIN)); // for(double[] e:allNum) { // for(double r:e) { // System.out.print(r); // } // } } }