📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Type
zjj=(RBall,GBall,BBall); //定义枚举类型
{$R *.dfm}
Function meth(zjf:zjj):String;//自定义函数
begin
Case zjf of
RBall:meth:='红';
GBall:meth:='绿';
BBall:meth:='蓝';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
zj1,zj2,zj3:zjj; //声明枚举变量
str,str1,str2,str3:String;
begin
str:='';
for zj1:=Low(zjj) to High(zjj) do //循环变量为枚举类型
begin
str1:=meth(zj1);
for zj2:=Low(zjj) to High(zjj) do
begin
if (zj2<>zj1) then
begin
str2:=meth(zj2);
for zj3:=Low(zjj) to High(zjj) do
if ((zj3<>zj1)And(zj3<>zj2))then
begin
str3:=meth(zj3);
str:=str+str1+str2+str3+' ';//找到一种不同颜色的球就添加上
end; //此处end语句很多,注意不要漏掉或多写
end;
end;
end;
if Length(str)>33 then
begin
str1:=Copy(str,1,33); //字符串太长就截取为两段
str2:=Copy(str,34,Length(str));
Canvas.TextOut(65,25,'中奖的不同颜色球如下');
Canvas.TextOut(30,65,str1);
Canvas.TextOut(30,90,str2);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -