Re: algorithms + data structures = programs
- From: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>
- Date: Sun, 23 Jul 2006 19:38:37 +0000
arnuld said:
<snip>
r := 10*r + d[i]
d[i] := r div 2
r := r-2*d[i]
more *shocking* is its implmentation in PASCAL.
Okay, let's take a look:
program power(output);
{ decimal representation of negative powers of 2 }
const n = 10;
type digit = 0..9;
var i,k,r: integer;
d: array[1..n] of digit;
begin
for k := 1 to n do
begin
write('.');
r := 0;
for i := 1 to k - 1 do
begin
r := 10 * r + d[i];
d[i] := r div 2;
r := r - 2 * d[i];
write(chr(d[i] + ord('0')))
end ;
d[k] := 5;
writeln('5');
end
end .
Yes, okay, I agree. I'm appalled. :-)
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.
- Follow-Ups:
- Re: algorithms + data structures = programs
- From: arnuld
- Re: algorithms + data structures = programs
- References:
- algorithms + data structures = programs
- From: arnuld
- Re: algorithms + data structures = programs
- From: Richard Heathfield
- Re: algorithms + data structures = programs
- From: arnuld
- algorithms + data structures = programs
- Prev by Date: Re: Endianess
- Next by Date: Re: algorithms + data structures = programs
- Previous by thread: Re: algorithms + data structures = programs
- Next by thread: Re: algorithms + data structures = programs
- Index(es):
Relevant Pages
|