Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,46 @@
|
|||
*process source attributes xref;
|
||||
/* Handles both negative and positive values. */
|
||||
Beadsort: Proc Options(main);
|
||||
Dcl sysprint Print;
|
||||
Dcl (hbound,max,min) Builtin;
|
||||
|
||||
Dcl z(10) Bin Fixed(31) Init(10,-12,1,0,999,8,2,2,4,4);
|
||||
Dcl s(10) Bin Fixed(31);
|
||||
Dcl (init,lo,hi) Bin Fixed(31) Init(0);
|
||||
Dcl (i,j) Bin Fixed(31) Init(0);
|
||||
|
||||
Call minmax(z,init,lo,hi);
|
||||
|
||||
Begin;
|
||||
Dcl beads(lo:hi) Bin Fixed(31);
|
||||
beads=0;
|
||||
Do i=1 To hbound(z);
|
||||
beads(z(i))+=1;
|
||||
End;
|
||||
Do i=lo To hi;
|
||||
Do While(beads(i)>0);
|
||||
j+=1;
|
||||
s(j)=i;
|
||||
beads(i)-=1;
|
||||
End;
|
||||
End;
|
||||
Put Edit(' Input:',(z(i) Do i=1 To hbound(z)))(skip,a,99(f(4)));
|
||||
Put Edit('Sorted:',(s(i) Do i=1 To hbound(s)))(skip,a,99(f(4)));
|
||||
End;
|
||||
|
||||
minmax: Proc(z,init,lo,hi);
|
||||
Dcl z(*) Bin Fixed(31);
|
||||
Dcl (init,lo,hi) Bin Fixed(31);
|
||||
Do i=1 To hbound(z);
|
||||
If init=0 Then Do;
|
||||
init=1;
|
||||
lo,hi=z(i);
|
||||
End;
|
||||
Else Do;
|
||||
lo=min(lo,z(i));
|
||||
hi=max(hi,z(i));
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
End;
|
||||
Loading…
Add table
Add a link
Reference in a new issue