piksr2.dem

来自「Delphi Pascal 数据挖掘领域算法包 数值算法大全」· DEM 代码 · 共 61 行

DEM
61
字号
PROGRAM d8r2(input,output,dfile);
(* driver for routine PIKSR2 *)
CONST
   np=100;
TYPE
   glsarray = ARRAY [1..np] OF real;
VAR
   i,j : integer;
   a,b : glsarray;
   dfile : text;

(*$I MODFILE.PAS *)
(*$I PIKSR2.PAS *)

BEGIN
   glopen(dfile,'tarray.dat');
   readln(dfile);
   FOR i := 1 to np DO BEGIN
      read(dfile,a[i])
   END;
   close(dfile);
(* generate b-array *)
   FOR i := 1 to np DO BEGIN
      b[i] := i-1
   END;
(* sort a and mix b *)
   piksr2(np,a,b);
   writeln('after sorting a and mixing b, array a is:');
   FOR i := 1 to 10 DO BEGIN
      FOR j := 1 to 10 DO BEGIN
         write(a[10*(i-1)+j]:6:2)
      END;
      writeln
   END;
   writeln('... and array b is:');
   FOR i := 1 to 10 DO BEGIN
      FOR j := 1 to 10 DO BEGIN
         write(b[10*(i-1)+j]:6:2)
      END;
      writeln
   END;
   writeln('press return to continue ...');
   readln;
(* sort b and mix a *)
   piksr2(np,b,a);
   writeln('after sorting b and mixing a, array a is:');
   FOR i := 1 to 10 DO BEGIN
      FOR j := 1 to 10 DO BEGIN
         write(a[10*(i-1)+j]:6:2)
      END;
      writeln
   END;
   writeln('... and array b is:');
   FOR i := 1 to 10 DO BEGIN
      FOR j := 1 to 10 DO BEGIN
         write(b[10*(i-1)+j]:6:2)
      END;
      writeln
   END
END.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?