Package QSort
\
  QSort, version de base
                         \
Uses IO

Const
     max=999
Var
   t As Array[1..max] Of Int
   i,Signature As Int

Sub Sort(l,r As Int)
Var
   i,j,x,y As Int
Enter
  Signature=Signature+1
  i=l:j=r:x=t[(l+r)/2]
  While i<=j Do
  Begin
    While t[i]<x Do i=i+1;
    While x<t[j] Do j=j-1;
    If i<=j Then
      y=t[i]:t[i]=t[j]:t[j]=y
      i=i+1:j=j-1
    End
  Wend
  If l<j Then Sort l,j;
  If i<r Then Sort i,r;
Leave

Def Random(N As Int) As Int
Enter
  Result=24569-(24569/N)*N
Leave

Enter
\
  Sign set \
  Signature=0
\
  Fill & Print(T) \
  PrintS "Tirage al‚atoire des valeurs..."
  PrintCR
  For i=1 to max Do T[i]=Random(i);
\ For i=1 to max Do PrintX T[i]:PutCar ' '; \
\
  Sort(T) \
  PrintS "Nous trions les valeurs"
  PrintCR
  Sort 1,max
\
  Carriage
  PrintCR \
\
  PrintAfter(T) \
  PrintS "C'est torch‚, jte les balance"
  PrintCR
  For i=1 to max Do PrintX T[i]:PutCar ' ';
\
  Arrachos \
  PrintCR
  PrintS "Signature="
  PrintX Signature
Leave