delphi写的九九乘法表

delphi写的九九乘法表_第1张图片

delphi写的九九乘法表_第2张图片

初学delphi,最简单的程序了。没有运用到什么高深的东西。

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls;

type
  TForm1 = class(TForm)
    mmo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
 i,j,s,a,b,c:Integer;
 z,y,u,v:string;
begin
   mmo1.Clear;
  for i := 9 downto 1 do
    begin
      for j := i downto 1 do
         begin
         s:=i*j;
         if s>9 then
            y:='  |'
         else
            y:='    |';
         z:=z+inttostr(i)+'x'+inttostr(j)+'='+inttostr(s)+y;//format('%-5d',[s]);
         end;
      mmo1.Lines.Add(z);
      z:='';
    end;
    for a := 1 to 9 do
    begin
      for b := 1 to  a do
         begin
         c:=a*b;
         if c>9 then
            begin
            u:='  |';
            v:=v+inttostr(b)+'x'+inttostr(a)+'='+inttostr(c)+u;
            end
         else
            begin
            u:='    |';
            v:=v+inttostr(b)+'x'+inttostr(a)+'='+inttostr(c)+u;
            end;

         end;
      mmo1.Lines.Add(v);
      v:='';
    end;

end;
end.

你可能感兴趣的:(delphi写的九九乘法表)