Apparently the large buffer is not an advantage since testing with BUFSIZ instead of 0x80000 gave timings of 0.81, 0.75 and 0.85:
#include <stdio.h>
#define N BUFSIZ
unsigned char inputv[N];...
Type: Posts; User: laserlight
Apparently the large buffer is not an advantage since testing with BUFSIZ instead of 0x80000 gave timings of 0.81, 0.75 and 0.85:
#include <stdio.h>
#define N BUFSIZ
unsigned char inputv[N];...
I believe that there is an edge case bug in the code: in the case where the input is 1000000000, the fgets() will read 10 characters in and then insert the null character. However, that leaves the...
To be fair, the rules in a "competition" are different from the normal rules of programming/software engineering, so I would accept gets() in this case since the input is guaranteed to be correct....
Yes, I finally decided to let the site do the benchmarking for me, and finished with about the same timing with a similiar approach, since it was the next obvious implementation that actually made...
Naive? Straightforward is more like it :), and it is similiar to what samus250 did, hence the similiar timing. Incidentally, scanf and printf belong to the std namespace. Actually, with this...
Well, that is an example of why we should measure when we want to determine performance :)
Nonetheless, why not show the source code of both the programs involved?
That is interesting. You mean that using dynamic memory allocation is an improvement? I do not see a space-time trade-off benefit here, so that is puzzling.
In that case, consider switching to C-style input to see if it makes any difference.
It does not look like dynamic memory allocation is actually needed.