懂Delphi的进!!!!!!!编程有点小麻烦
你把下面的代码全部替代你的单元代码就可以了:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure showAllPrime(wide: integer);
function isPrime(number: integer): boolean;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.showAllPrime(wide: integer);
var
iCount:integer;
begin
//排除掉1,1不是素数,不是质数,也不是合数
icount:=strtoint(edit1.Text);
if icount=1 then
edit2.Text:= '1不是素数!'
else
begin
if isPrime(iCount) then
begin
edit2.Text:=intTostr(iCount)+'是素数!';
end
else
begin
edit2.Text:=intTostr(iCount)+'不是素数!';
end;
end;
end;
function TForm1.isPrime(number: integer): boolean;
var
iHalf,iCount:integer;
begin
result:=true;
iHalf:=Round(SQRT(number));
for iCount:=2 to iHalf do
begin
if (number mod iCount)=0 then
begin
result:=false;
break;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
n:Integer;
m:real;
begin
m:=strtofloat(edit1.Text);
n:=round(m);
if n
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!