Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Gray-code/Draco/gray-code.draco
Normal file
28
Task/Gray-code/Draco/gray-code.draco
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
proc gray_encode(word n) word:
|
||||
n >< (n >> 1)
|
||||
corp
|
||||
|
||||
proc gray_decode(word n) word:
|
||||
word r;
|
||||
r := n;
|
||||
while
|
||||
n := n >> 1;
|
||||
n > 0
|
||||
do
|
||||
r := r >< n
|
||||
od;
|
||||
r
|
||||
corp
|
||||
|
||||
proc main() void:
|
||||
word i, enc, dec;
|
||||
for i from 0 upto 31 do
|
||||
enc := gray_encode(i);
|
||||
dec := gray_decode(enc);
|
||||
writeln(i:2, ": ",
|
||||
i:b:5, " => ",
|
||||
enc:b:5, " => ",
|
||||
dec:b:5, " => ",
|
||||
dec:2)
|
||||
od
|
||||
corp
|
||||
Loading…
Add table
Add a link
Reference in a new issue