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

📄 unit1.~pas

📁 采用DELPHI实现哥德巴赫猜想
💻 ~PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  a,b,c,e,g : Integer;
  d : boolean;
begin
try
  StrToInt(Edit1.Text);
except
  showmessage('必需输入整数');
  exit;
end;
  a := StrToInt(Edit1.Text);
  Edit2.Text := '结果:不符合';
  if ((a Mod 2) = 0) and (a >= 6) then
  begin
    for b:=2 to a do
    begin
      d := False;
      for c := b - 1 downto 2 do
      begin
        if (b mod c) = 0 then
          break
        else
        begin
          e := a - b;
          for g := e - 1 downto 2 do
          begin
            if e mod g = 0 then
            begin
              d := False;
              break;
            end;
            d := True;
          end;
        end;
        if d=True then break;
     end;
     if d=True then
     begin
       Edit2.Text := '结果:符合!'+'  '+IntToStr(a)+'='+IntToStr(e)+'+'+IntToStr(b);
       break;
     end
     else
       Edit2.Text := '结果:不符合';
    end;
  end;
end;

end.

⌨️ 快捷键说明

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