unit1.~pas

来自「第五章练习题」· ~PAS 代码 · 共 55 行

~PAS
55
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Panel1: TPanel;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    procedure FormClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormClick(Sender: TObject);
var
x,y,m,n,i,j,k:integer;
p,q:real;
s:string;
begin
n:=strtoint(edit1.Text);
x:=0;y:=0;i:=2;j:=2;
for i:=1 to n do
begin
m:=n-i;
p:=strtofloat(inttostr(i));
q:=strtofloat(inttostr(m));
while(j<=sqrt(p))and(x=0)do
if i mod j=0 then x:=1;
while(k<=sqrt(q))and(y=0)do
if m mod k=0 then y:=1;
if (x=0)and(y=0)then
label3.Caption:=edit1.Text+'='+inttostr(i)+'+'+inttostr(m);
end;
end;

end.

⌨️ 快捷键说明

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