Razii said:
<snip>
>
> $ time sum.exe <sum.txt
> 11161 14831
>
> real 0m1.269s
> user 0m1.185s
> sys 0m0.015s
>
> this is not much faster than the original c++ version. What is
> 11161 14831? that's not the right answer.
<shrug> I have no idea. It's bog-standard C, and it works just fine here.
If you think the program is broken, perhaps you'd care to explain what
rule of C you think I've breached?
> Using the same file with java version I get
>
> $ time java -server sumcol <sum.txt
> 2462944
>
> real 0m0.742s
> user 0m0.015s
> sys 0m0.015s
>
> the answer should be 2462944
My timings with a 17993728-byte input file are as follows:
C: 1.33 seconds
C++: 1.44 seconds
Java: 17.59 seconds
and all three programs give the same result (which is obviously different
to yours, because I used more data). Since the original input file was
1000 lines totalling 500 each, I would expect the answer for my data
(which was 4096 times as big) to be 4096 * 500, or 2048000, which is
indeed the result given by my C version, my C++ version, and the site's
Java version.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www.
+rjh@[EMAIL PROTECTED]
users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


|