Re: algorithms + data structures = programs
- From: "arnuld" <arnuld3@xxxxxxxxx>
- Date: 23 Jul 2006 12:51:52 -0700
Richard Heathfield wrote:
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. :-)
hey Rich, i need help.
"arnuld"
.
- Follow-Ups:
- Re: algorithms + data structures = programs
- From: Richard Heathfield
- 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
- Re: algorithms + data structures = programs
- From: Richard Heathfield
- algorithms + data structures = programs
- Prev by Date: Re: algorithms + data structures = programs
- Next by Date: 5000 RapidShare Ebooks
- Previous by thread: Re: algorithms + data structures = programs
- Next by thread: Re: algorithms + data structures = programs
- Index(es):
Relevant Pages
|