×

# Unable to submit the solution to a problem

 0 I have written the code to the following problem The output I am getting is correct but still it shows wrong answer.I have read FAQs but still no nuccess.Where I am doing wrong.(I am a new user to codechef and joined today only) Here is my code  import java.io.*; class abc { public static void main(String args[]) { try{ String num; BufferedReader in=new BufferedReader(new FileReader("in.txt")); BufferedWriter out=new BufferedWriter(new FileWriter("out.txt")); while((num=in.readLine())!=null) { if(Integer.parseInt(num)==42) break; else out.write(num+"\n"); } in.close(); out.close(); }catch(Exception e) { System.out.println("File not found"); } } }  asked 01 Oct '13, 23:42 1●1●2 accept rate: 0%

 1 You missed that program have to read from stdin - http://www.codechef.com/wiki/faq#How_should_I_test_my_program answered 01 Oct '13, 23:47 16.9k●49●115●225 accept rate: 11%
 0 @codernavi18 : Who told you that input will be available in file named "in.txt" and that you have to create a output file and that you can print messages . You have read your input from Standard Input i.e write , BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); And write your output to standard output i.e. write , BufferedWriter out=new BufferedWriter(System.out); General Tip : You should not print any messages also , you can assume input to match constraints given in the problem and your output should match exactly the format mentioned in problem statement . answered 01 Oct '13, 23:47 12.4k●47●107●171 accept rate: 12%
 0 @codernavi18 Read the sample solutions, especially, sample solution in Java, to get a feel of how problem solving is done in codechef. answered 02 Oct '13, 09:41 4.2k●5●23●64 accept rate: 15%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,319
×335

question asked: 01 Oct '13, 23:42

question was seen: 1,599 times

last updated: 02 Oct '13, 09:41