I think you can do it as you want (but I have NOT read the rules of code jam - if you have to upload your code, it might be required to read the input-file exactly as specified)
However, reading from a file (and writing to the other file) will be far easier when the files are longer (for example, if you have a list of 30 coordinates to read or write). In addition, it simplifies testing: you can run your code on a small input first to make sure it's working correctly. so, I'd recommend you to read & write to/from files - you can write the logic once and then just use it. Axel Am 01.04.2013 19:26 schrieb "ZHANG Xiongqi, Parker" <[email protected] >: > I think you can use > > System.setIn(new FileInputStream("code_jam_**input_file.txt")); > System.setOut(new PrintStream("code_jam_output_**file.txt")); > > These two line should let you read from txt file and write to a txt file. > > Parker > > On 2013/3/30 21:37, Chandra Sekhar wrote: > >> Hi All, >> >> I am going to participate Google Code JAM 2013. So before that I >> thought to practice a bit. I found the inputs are given in a file and the >> output is expected in a file only. So my question is do I need to write >> some IO operations to read the question from file and after calculating the >> output do I again need to write that back to another destination file >> through code. >> >> Or I can copy the the input file contents to my code and just write >> the code and after getting the output in the console, I can copy the output >> to a file to send as output file. >> >> For Example: the input of a contest >> >> 3 >> 100 >> 3 >> 5 75 25 >> >> >> Can I write the code like >> >> int index = 3, credit = 100, noOfProducts = 3; >> int[] prices = {5,75,25}; >> >> //Code to calculate output starts here >> >> System.out.print(output); >> //After getting the output into console copy it into a file and send >> it as an output file. >> >> >> >> Or I need to write like this >> >> FileInputStream fis = new FileInputStream("code_jam_** >> input_file.txt"); >> //read the input file and parse the content and then start >> calculating the output >> >> //After getting the output write back it to a destination output file >> and then send it to Google. >> >> >> >> >> Thanks. >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Code Jam" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to >> google-code+unsubscribe@**googlegroups.com<google-code%[email protected]> >> . >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit https://groups.google.com/d/** >> msg/google-code/-/867rZfbqOKgJ<https://groups.google.com/d/msg/google-code/-/867rZfbqOKgJ> >> **. >> For more options, visit >> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >> . >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to > google-code+unsubscribe@**googlegroups.com<google-code%[email protected]> > . > To post to this group, send email to [email protected]. > For more options, visit > https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . > > > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
