Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Your code doesn't return -1 when bounce is 1
If bounce is 1 and h is greater than window, it will always be greater than window so the loop runs forever.
I don't see it either, but since the code uses the nonstandard function strrev(), it's automatically non-portable even without plusDot().
may i know where does
plusDot
come from?This comment is hidden because it contains spoiler information about the solution
I got it, thank you!
This comment is hidden because it contains spoiler information about the solution
maybe the equation result should be
n > log(window/h) / log(bounce)
? Sincebounce < 1
, thenlog(bounce) < 0
. So we useceil
here.The thing is that the width specifiers don't dictate the particular argument length, but only maximum.
So the string with exact same length can have value that doesn't fit the pattern but will be accepted if we remove this check.
may anyone explain the code started from
b += c > 1
? I don't understand whyc
, which is index, is added to pointerb
. This expression will give value of b after assigning, which must be > 1. Also, will this update pointerb
and left some memory unused?Besides, as a terminating null character is automatically appended after the content written in
snprintf
, how can the code solve this problem?thx for your reply, but the code has already checked whether strlen(number) == frmt_len, input with incorrect length cannot pass the condition. May anyone explain this to me please?
it is used to catch any extra trailing characters, then sscanf would return 8, and not 7, therefore when it returns exactly 7 we are sure that we don't have any trailing characters.
may i know why %1s is used at the sscanf function? Thank you.