unit unit4;
inte***ce
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;
type
tenum = (one, two, three, four, five, six, seven, eight, nine, ten);
tsetenum = set of tenum;
tform4 = class(tform)
groupbox1: tgroupbox;
button1: tbutton;
button2: tbutton;
groupbox2: tgroupbox;
button3: tbutton;
button4: tbutton;
button5: tbutton;
button6: tbutton;
button7: tbutton;
button8: tbutton;
button9: tbutton;
procedure button1click(sender: tobject);
procedure button2click(sender: tobject);
procedure button3click(sender: tobject);
procedure button5click(sender: tobject);
procedure button6click(sender: tobject);
procedure button7click(sender: tobject);
procedure button4click(sender: tobject);
procedure button8click(sender: tobject);
procedure button9click(sender: tobject);
private
setenum, setenum1, setenum2: tsetenum ;
public
end;
varform4: tform4;
implementation
procedure tform4.button1click(sender: tobject);
vars1, s2: string;
begin
s1 := 'aaa';
s2 := s1;
s2 := 'bbb';
showmessage('字串s1的值: ' + s1 + ' ; 字串s2的值: ' + s2);
end;
procedure tform4.button2click(sender: tobject);
vara1, a2: array of string;
begin
setlength(a1, 1);
a1[0] := 'aaa';
a2 := a1;
a2[0] := 'bbb';
showmessage('陣列a1的值:' + a1[0]+ ' ;陣列a2的值:' + a2[0]);
end;
//初始化
procedure tform4.button3click(sender: tobject);
begin
setenum := [one, two];
setenum1 := [three, nine, ten]
end;
//集合減少
procedure tform4.button5click(sender: tobject);
begin
setenum := setenum - [two];
end;
//集合增加
procedure tform4.button6click(sender: tobject);
begin
setenum := setenum + [three];
end;
//集合減少
procedure tform4.button7click(sender: tobject);
begin
exclude(setenum, one);
end;
//集合增加
procedure tform4.button4click(sender: tobject);
begin
include(setenum, four);
include(setenum, ten);
end;
//執行校驗
procedure tform4.button8click(sender: tobject);
begin
if one in setenum then
begin
showmessage('exclude函式執行失敗');
endelse if two in setenum then
begin
showmessage('setenum - [two]執行失敗');
endelse if not (three in setenum) then
begin
showmessage('setenum + [three]執行失敗');
endelse if not (four in setenum) then
begin
showmessage('include函式執行失敗');
endelse if not (ten in setenum) then
begin
showmessage('include函式執行失敗');
endelse
begin
showmessage('執行成功!');
end;
end;
//取得集合的交集
procedure tform4.button9click(sender: tobject);
begin
setenum2 := setenum1 * setenum;
if three in setenum2 then
begin
showmessage('交集成功執行成功');
end;
end;
end.
//
集合的用法
list集合的特有功能概述和測試 list集合儲存學生物件並遍歷 併發修改異常產生的原因及解決方案 iterator it list.iterator while it.hasnext listiterator vector的特有功能 資料結構中的陣列和鍊錶 list的三個子類的特點 vector和...
delphi中Format的用法
format是乙個很常用方法,並且使用它可以實現眾多格式的轉變.因此學會使用format是非常重要的.首先看它的宣告 function format const format string const args array of const string overload 事實上format方法有兩...
delphi中指標的用法
delphi中指標的用法 delphi學習 object pascal的指標 kendy 發表於 2005 2 19 14 14 00 大家都認為,c語言之所以強大,以及其自由性,很大部分體現在其靈活的指標運用上。因此,說指標是c語言的靈魂,一點都不為過。同時,這種說法也讓很多人 產生誤解,似乎只有...