Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Van-Eck-sequence/Cowgol/van-eck-sequence.cowgol
Normal file
33
Task/Van-Eck-sequence/Cowgol/van-eck-sequence.cowgol
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
include "cowgol.coh";
|
||||
|
||||
sub print_list(ptr: [uint16], n: uint8) is
|
||||
while n > 0 loop
|
||||
print_i16([ptr]);
|
||||
print_char(' ');
|
||||
n := n - 1;
|
||||
ptr := @next ptr;
|
||||
end loop;
|
||||
print_nl();
|
||||
end sub;
|
||||
|
||||
const LIMIT := 1000;
|
||||
var eck: uint16[LIMIT];
|
||||
MemZero(&eck as [uint8], @bytesof eck);
|
||||
var i: @indexof eck;
|
||||
var j: @indexof eck;
|
||||
|
||||
i := 0;
|
||||
while i < LIMIT-1 loop
|
||||
j := i-1;
|
||||
while j != -1 loop
|
||||
if eck[i] == eck[j] then
|
||||
eck[i+1] := i-j;
|
||||
break;
|
||||
end if;
|
||||
j := j - 1;
|
||||
end loop;
|
||||
i := i + 1;
|
||||
end loop;
|
||||
|
||||
print_list(&eck[0], 10);
|
||||
print_list(&eck[LIMIT-10], 10);
|
||||
Loading…
Add table
Add a link
Reference in a new issue