A couple of things:

1) set() should have a return type of void. Trivial, but if it doesn't return a 
value, it should have a void type.

2) Also in set(), j1 and k1 are not initialized, and some input will cause 
those two variables to be used without ever being set.

I recommend turning the warning levels on your compiler up so you get warnings 
about risky programming practice.  I'm using g++ with -pedantic_errors, it's 
very useful.

The only real problems I found were probably because it couldn't find the input 
file, and it didn't terminate or properly report the errors.

Instead of this:
        if(f1==NULL)
                printf("error in f1\n");
        if(f2==NULL)
                printf("error in f2\n");

This would be better:
        if(f1==NULL) {
                printf("Could not open input file\n");
                exit(1);
        }
        if(f2==NULL) {
                printf("Could not open output file\n"); 
                fclose(f1);
                exit(1);
        }

With this change I was able to see the input file was incorrectly named, and it 
appears to work now (at least it runs and produces input, which I didn't check).

Hope that helps...

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/570fc578-6961-497f-849b-43cd80a82dc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to