|
|
вернуться в форумGetting Restricted Function for Problem 1001.Reverse Root import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.text.DecimalFormat; import java.util.Stack; public class ReverseRoot {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("Test.txt")); Stack<Double> stack = new Stack<Double>(); String str; while((str = br.readLine()) != null) { String[] tokens = str.trim().replaceAll("\\s+", " ").split(" "); for(String st : tokens) { if(!st.equals("")) stack.push(Double.parseDouble(st)); } }
br.close();
final String decimalFormatStr = "0.0000"; DecimalFormat df = new DecimalFormat(decimalFormatStr); while(stack.size() != 0) { System.out.println(df.format(Math.sqrt(stack.pop()))); }
}
} Re: Getting Restricted Function for Problem 1001.Reverse Root > BufferedReader br = new BufferedReader(new FileReader("Test.txt")); http://acm.timus.ru/help.aspx?topic=judgeThe program must be a console application. Input data must be read from the standard input (input from the keyboard). Output data must be printed to the standard output (screen output). Re: Getting Restricted Function for Problem 1001.Reverse Root Thanks a lot for pointing the issue. I will change the implementation and repost it. |
|
|