Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Gray-code/PowerBASIC/gray-code.basic
Normal file
18
Task/Gray-code/PowerBASIC/gray-code.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function gray%(byval n%)
|
||||
gray%=n% xor (n%\2)
|
||||
end function
|
||||
|
||||
function igray%(byval n%)
|
||||
r%=0
|
||||
while n%>0
|
||||
r%=r% xor n%
|
||||
shift right n%,1
|
||||
wend
|
||||
igray%=r%
|
||||
end function
|
||||
|
||||
print " N GRAY INV"
|
||||
for n%=0 to 31
|
||||
g%=gray%(n%)
|
||||
print bin$(n%);" ";bin$(g%);" ";bin$(igray%(g%))
|
||||
next
|
||||
Loading…
Add table
Add a link
Reference in a new issue