📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ISET:^integer; GSET:^real;
implementation
//PROGRAM D7F1
//Driver for routine GASDEV
uses
unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
const
s1='%10.4f'; s2='%5.2f';
N = 20; NP1 = N + 1; NOVER2 = N div 2; NPTS = 10000;
ISCAL = 400; LLEN = 50;
var
DIST:array[0..21] of real; STR1:string;
F:TextFile;
I,J,K,IDUM,KLIM:integer; X:real;
begin
New(ISET); New(GSET);
Randomize;
For I:=1 To NP1 do
DIST[I]:= 1;
For I:= 1 To NPTS do
begin
J:= Round(0.25 * N * GASDEV) + NOVER2 + 1;
If (J >= 1) And (J <= NP1) Then DIST[J]:= DIST[J] + 1;
END;
//输出计算结果到文件
AssignFile(F, 'd:\delphi_shu\p7\d7f1.dat');
Rewrite(F);
Writeln(F,'Normally distributed deviate of ',
FormatFloat('####0',NPTS),' points');
Writeln(F);
Writeln(F,' x p(x) graph:');
For J:= 1 To NP1 do
begin
DIST[J]:= DIST[J] / NPTS;
KLIM:= Trunc(ISCAL * DIST[J]);
If KLIM > LLEN Then KLIM:= LLEN;
STR1:=' ';
For I:= 1 To KLIM do
STR1:= STR1 + '*';
X:= J / (0.25 * N);
Writeln(F,' ',Format(s2,[X]),Format(s1,[DIST[J]]),' ',STR1);
end;
CloseFile(F);
//屏幕显示计算结果
memo1.Lines.LoadFromFile('d:\delphi_shu\p7\d7f1.dat');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -