← Back to topics
Topic

z-factorial

varlevani
I used gets in my program and it failed on 8 tests ( from 10). when I changed it to scanf it worked. Is it system's bug? Or we shuldn't use gets in programs?
varlevani
I see , that aropan also used gets and got 20 points.
adminModerator
gets doesn't truncate the input (if there is a space after the last character)
adminModerator
or a newline character...

i guess i should fix the test cases and re-grade
boris4
i have gets in z-knight and in z-sudoku, can that be problem ??
varlevani
Yes , I understood. I wasn't reading only '!' characters.
Thanks.
nemanja1990
that isn't very nice

i understand that examples aren't made bu you, but they sould be as it says in the task
varlevani
@boris4
In z-knight you had to read till the end of input and gets does it.
adminModerator
@boris:

your z-knight is not correct, it doesn't sort the output corretly

also you should never use gets (look at the compiler output)

ss.cc:(.text+0x412): warning: the `gets' function is dangerous and should not be used.
boris4
i don't have that compiler output..

I have solved some problems using gets

What sort ?

int const dx[] = { -2, -1, 1, 2, 2, 1, -1, -2 };
int const dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 };

I should just output in clockwise, and I am doing that.
oduleodule

Is it hard problem to count number of consecutive '!'s on input line?

I don't think so!

Ok, i agree to admin to revalidate, with new checker, but as competitors You must handle various formats on input and output.

Think about this situation, in Your next competition.
adminModerator
for this test case

a8 f3

you output:

d4 e5 g5 h4 h2 g1 e1 d2

and it should be:

g5 h4 h2 g1 e1 d2 d4 e5
varlevani
@boris4:
I used arrays :

const int ia[8]={1,2,2,1,-1,-2,-2,-1};
const int ja[8]={2,1,-1,-2,-2,-1,1,2};
adminModerator
@boris: you switched rows and columns i guess
boris4
yes i switched row and column and dx[] isn't correct because first he needs to go up... so

int const dx[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
int const dy[] = { 2, 1, -1, -2, -2, -1, 1, 2 };

is correct

stupid mistake...

thx all.