⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 《Delphi常用数值算法集》的配书源码
💻 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;
type
  matrx2=array of array of real;
var
  Form1: TForm1;

implementation
//PROGRAM D8R11
//Driver for routine ZROOTS
uses
  unit2;
  {$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
const
  s1='%14.6f';  s2='##';
  M = 4; MP1 = M+1;
var
  F:TextFile;
  A,ROOTS:matrx2;
  I,J,N,IFLAG:integer;   AAA,BBB:real;
  POLISH:boolean;
begin
  SetLength(A,3,6);
  SetLength(ROOTS,3,5);
  For J:= 1 To MP1 do
    For I:= 1 To 2 do
      A[I, J]:=0;
  A[2, 1]:=2;
  A[1, 3]:=-1;
  A[2, 3]:=-2;
  A[1, 5]:=1;
  //输出计算结果到文件
  AssignFile(F, 'd:\delphi_shu\p8\d8r11.dat');
  Rewrite(F);
  Writeln(F, 'Roots of polynomial x^4-(1+2i)*x^2+2i');
  Writeln(F);
  N:=0;
  POLISH:=false;
  ZROOTS(A,M,ROOTS,POLISH);
  Writeln(F, 'Unpolished roots:');
  Writeln(F, '    Root #     Real          Imag.');
  For I:= 1 To M do
    Writeln(F, '      ',FormatFloat(s2,I),Format(s1,[ROOTS[1, I]]),
               Format(s1,[ROOTS[2, I]]));
  Writeln(F);
  Writeln(F, 'Corrupted roots:');
  For I:= 1 To M do
  begin
    ROOTS[1, I]:= ROOTS[1, I] * (1 + 0.01 * I);
    ROOTS[2, I]:= ROOTS[2, I] * (1 + 0.01 * I);
  end;
  Writeln(F, '    Roots #    Real          Imag.');
  For I:= 1 To M do
    Writeln(F, '      ',FormatFloat(s2,I),Format(s1,[ROOTS[1, I]]),
               Format(s1,[ROOTS[2, I]]));
  POLISH:= true;
  ZROOTS(A, M, ROOTS, POLISH);
  Writeln(F);
  Writeln(F, 'Polished roots:');
  Writeln(F, '    Roots #    Real          Imag.');
  For I:= 1 To M do
    Writeln(F, '      ',FormatFloat(s2,I),Format(s1,[ROOTS[1, I]]),
               Format(s1,[ROOTS[2, I]]));
   CloseFile(F);
  //屏幕显示计算结果
  memo1.Lines.LoadFromFile('d:\delphi_shu\p8\d8r11.dat');
end;

end.

⌨️ 快捷键说明

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