好友
阅读权限20
听众
最后登录1970-1-1
|
本帖最后由 Survivor 于 2016-7-15 10:22 编辑
回帖有奖80%中奖率
运行截图:
源码如下:[Delphi] 纯文本查看 复制代码 unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
lbl1: TLabel;
lbl2: TLabel;
btn1: TButton;
btn2: TButton;
btn3: TButton;
btn4: TButton;
btn5: TButton;
btn7: TButton;
btn8: TButton;
btn6: TButton;
edt0: TEdit;
img1: TImage;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure btn5Click(Sender: TObject);
procedure edt1Click(Sender: TObject);
procedure edt2Click(Sender: TObject);
procedure btn7Click(Sender: TObject);
procedure btn8Click(Sender: TObject);
procedure btn6Click(Sender: TObject);
procedure edt1Change(Sender: TObject);
procedure edt2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
temp: Real ;
i:Cardinal =0 ;
formula,formula1,formula2 :string ;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption := '+';
temp:= StrToFloat(edt1.Text )+ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'+'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption := '+';
temp:= StrToFloat(edt1.Text )+ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'+'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption := '-';
temp:= StrToFloat(edt1.Text )- StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'-'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption := '-';
temp:= StrToFloat(edt1.Text )- StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'-'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
end ;
procedure TForm1.btn3Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption :='×';
temp:= StrToFloat(edt1.Text )* StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'×'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption :='×';
temp:= StrToFloat(edt1.Text )* StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :='('+formula1 +')'+'×'+'('+formula2+')';
edt0.Text :=formula +'='+edt3.Text ;
end
end;
procedure TForm1.btn4Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption :='÷';
temp:= StrToFloat(edt1.Text )/ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'÷'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption :='÷';
temp:= StrToFloat(edt1.Text )/ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :='('+formula1 +')'+'÷'+'('+formula2+')';
edt0.Text :=formula +'='+edt3.Text ;
end
end ;
procedure TForm1.btn5Click(Sender: TObject);
begin
lbl1.Caption :='?';
edt1.Text:='0';
edt2.Text :='0';
edt3.Text :='0';
temp :=0;
formula :=' ' ;
formula1 :=' ' ;
formula2 :=' ' ;
i :=0;
end;
procedure TForm1.edt1Click(Sender: TObject);
begin
edt1.SelectAll ;
end;
procedure TForm1.edt2Click(Sender: TObject);
begin
edt2.SelectAll ;
end;
procedure TForm1.btn7Click(Sender: TObject);
begin
inc (i);
edt1.Text:=edt3.Text ;
formula1 :=formula ;
edt2.SetFocus ;
edt2.SelectAll ;
end;
procedure TForm1.btn8Click(Sender: TObject);
begin
inc (i);
edt2.Text:=edt3.Text ;
formula2 :=formula ;
edt1.SetFocus ;
edt1.SelectAll ;
end;
procedure TForm1.btn6Click(Sender: TObject);
begin
Close ;
end;
procedure TForm1.edt1Change(Sender: TObject);
begin
formula1:=edt1.Text;
end;
procedure TForm1.edt2Change(Sender: TObject);
begin
formula2:=edt2.Text;
end;
end.
|
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|