ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

What is wrrong here?(in Java Compiler i get correct answer..)
Posted by ABO 1 Nov 2008 00:42
import java.io.FileReader;
import java.util.LinkedList;
import java.util.Scanner;

public class Pr1002 {

    public static void main(String[] args) {
        LinkedList<Long> listOfNum = new LinkedList<Long>();
        try {

            Scanner sc = new Scanner(new FileReader(args[0]));
            while (sc.hasNext()) {
                listOfNum.addFirst(sc.nextLong());
            }
            while (!listOfNum.isEmpty()) {
                System.out.printf("%.4f", Math.sqrt(listOfNum.removeFirst()));
                System.out.println();
            }

        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

    }
}
Re: What is wrrong here?(in Java Compiler i get correct answer..)
Posted by ld.alfredo 12 Nov 2008 06:29
>> Scanner sc = new Scanner(new FileReader(args[0]));
I think you're to assume all input comes from 'System.in' and not be specify as a program argument, so 'java myprogram inputfile.txt shouldn't work'.