• 虽然很简单,但是我忙活了半个下午,才写出来的小计算器


    图片

    unit Unit1;

    interface

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

    type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;
      x1 : integer;
      x2 : integer;
      x3 : integer;
      str1 : string;
      str2 : string;
      str3 : string;

    implementation

    {$R *.dfm}

    //+
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
        messagebox(handle , '输入两个数啊' , '出错' , 0 )
      else
        begin
        str1 := edit1.Text;
        str2 := edit2.Text;
        x1 := strtoint(str1);
        x2 := strtoint(str2);
        x3 := x1 + x2 ;
        str3 := inttostr(x3);
        edit3.Text := str3 ;
        end;
    end;

    //-
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
        messagebox(handle , '输入两个数啊' , '出错' , 0 )
      else
        begin
        str1 := edit1.Text;
        str2 := edit2.Text;
        x1 := strtoint(str1);
        x2 := strtoint(str2);
        x3 := x1 - x2 ;
        str3 := inttostr(x3);
        edit3.Text := str3 ;
        end;
    end;

    //*
    procedure TForm1.Button3Click(Sender: TObject);
    begin
      if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
        messagebox(handle , '输入两个数啊' , '出错' , 0 )
      else
        begin
        str1 := edit1.Text;
        str2 := edit2.Text;
        x1 := strtoint(str1);
        x2 := strtoint(str2);
        x3 := x1 * x2 ;
        str3 := inttostr(x3);
        edit3.Text := str3 ;
        end;
    end;

    ///
    procedure TForm1.Button4Click(Sender: TObject);
    begin
      if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
        messagebox(handle , '输入两个数啊' , '出错' , 0 )
      else
        begin
        str1 := edit1.Text;
        str2 := edit2.Text;
        x1 := strtoint(str1);
        x2 := strtoint(str2);
        x3 := round(x1 / x2) ;
        str3 := inttostr(x3);
        edit3.Text := str3 ;
        end;
    end;

    end.

  • 相关阅读:
    bzoj2064分裂(dp)
    关于逆元的学习笔记(尚未完成)
    线性基学习笔记
    bzoj2460元素(线性基,贪心)
    CF280C Game on tree(期望dp)
    XJOI contest800
    关闭极域电子教室学生端的各种方法
    大坑!有网,电脑qq登不上去!!
    4.25 ZJOI2017 10AM
    bzoj1621
  • 原文地址:https://www.cnblogs.com/suanguade/p/4038255.html
Copyright © 2020-2023  润新知