Maybe I'm using the wrong approach, but when I'm solving this kind of
problem I only create a class with a main method and all the output is
directed to the standard output printing a StringBuilder object that keep
storing the output after each "round" of the execution in the case of a
loop. As the standard output can be set to be a file, the different inputs
can be treated like this:

java Main < input-small.in > output-small.out
java Main < input-large.in > output-large.out
java Main < input-test.in > output-test.out

It's not pretty OO, but I think it's more simple. :)
--
Paulo Rômulo Alves Barros
MSc. Candidate in Computer Science
Embedded Systems and Pervasive Computing Lab
http://embedded.ufcg.edu.br/indexen.html



On Mon, Sep 7, 2009 at 2:37 PM, Ahmed Medhat <a.medhat...@gmail.com> wrote:

> thanks a lot Anil for your replay :)
>
> about the print function i use static import
> import static java.lang.System.out;
> so i can use
> out.println("blablabla");
>
> 2009/9/7 Anil Kishore <anil.dai...@gmail.com>
>
> Hmm.. looks fine. Take care of 'next()' and 'nextLine()' of the Scanner
>> class and try out a few things. Also, initialize two strings with the path
>> to directories of input and output files, if needed. Also, you may prepare a
>> small template to take number of test cases, put a loop and print 'Case #x:
>> ', as its the case with most of the problems in gcj.
>> You may also have a print function, to check things and print on standard
>> output.. (instead of writing System.out.println every time ) it can be
>> something like this. Try out a few things before using it in contest.
>>
>> final static void print(Object... ob) {
>>         System.out.println(Arrays.deepToString(ob));
>> }
>>
>> Efficiency in taking inputs and printing is not at a problem in gcj, as we
>> have enough time here (worst case 3-5secs delay is fine). Algorithm matters
>> the most.
>>
>> Finally, good to know that you shifted to Java ;)
>>
>> - AK
>>
>>
>>
>>
>> On Mon, Sep 7, 2009 at 10:27 PM, Ahmed Medhat <a.medhat...@gmail.com>wrote:
>>
>>> Dear all java coders,
>>>
>>> I was using C++ for coding in such computations and now I try to use Java
>>> and I use the following template please if there any comments about
>>> performance or if any one who have a another one which is more efficient
>>> than mine ?
>>>
>>>
>>>
>>> import java.io.*;
>>> import java.util.Scanner;
>>> /**
>>>  * @author: Ahmed.Medhat
>>>  * @Email:a.medhat...@gmail.com <email%3aa.medhat...@gmail.com>
>>>  * @CodeJam_Handel: Egy.Turing
>>>  */
>>> public class Test {
>>>
>>>     /* if test  -->0
>>>      * if small -->1
>>>      * if large -->2
>>>     */
>>>     int testType = 0;
>>>
>>>     Scanner sc;
>>>     PrintWriter pw;
>>>
>>>     Test()throws Exception{
>>>         init();
>>>
>>>         //Write the code here
>>>
>>>         pw.flush();
>>>         sc.close();
>>>     }
>>>     void init()throws Exception{
>>>         if(testType==0){
>>>             sc = new Scanner(new FileReader("c-test.in"));
>>>             pw = new PrintWriter(new FileWriter("c-test.out"));
>>>         }
>>>         else if(testType==1){
>>>             sc = new Scanner(new FileReader("c-small.in"));
>>>             pw = new PrintWriter(new FileWriter("c-small.out"));
>>>         }
>>>         else if(testType==2){
>>>             sc = new Scanner(new FileReader("c-large.in"));
>>>             pw = new PrintWriter(new FileWriter("c-large.out"));
>>>         }
>>>     }
>>>     public static void main(String[] args) throws Exception{
>>>         new Test();
>>>         System.exit(0);
>>>     }
>>> }
>>>
>>> --
>>> Kind Regards,
>>>
>>> Ahmed Medhat
>>> Computer Science
>>> Alexandria university
>>> Egypt
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Kind Regards,
>
> Ahmed Medhat
> Computer Science
> Alexandria university
> Egypt
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to google-code@googlegroups.com
To unsubscribe from this group, send email to 
google-code+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to