|
|
вернуться в форумWhat is wrong with this solution? Judge is giving output as Wrong Answer import java.util.Scanner; import java.util.Stack; public class ReverseRoot_SplitDecimal {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in); Stack<Integer> integerNumberStack = new Stack<Integer>(); Stack<Short> floatingNumberStack = new Stack<Short>();
Double tempDouble = new Double(0);
while(sc.hasNextInt()) { tempDouble = Math.sqrt(sc.nextDouble()); integerNumberStack.push(Integer.parseInt(String.format("%.4f", tempDouble).split("\\.")[0])); floatingNumberStack.push(Short.parseShort(String.format("%.4f", tempDouble).split("\\.")[1])); }
while(!integerNumberStack.isEmpty()) { System.out.printf("\n%d.%04d", integerNumberStack.pop(), floatingNumberStack.pop()); } System.out.println();
sc.close(); } } |
|
|