百钱百鸡

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Memo1: TMemo;
    Button1: TButton;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);   //“计算”按钮
var
  x,y,z: integer;
  p: string;
begin
  memo1.Clear;                                    //清除memo1的内容
  for x := 0 to 19 do
    for y := 0 to 33 do
      begin
        z := 100-x-y;
        if 5*x + 3*y + z/3 = 100 then
          begin
            p :=format('%3d %23d %23d',[x,y,z]);
            memo1.Lines.Add(p);
          end;
      end;
end;

end.

 

posted @ 2011-12-03 14:39  endsnow  阅读(126)  评论(0)    收藏  举报