Get A!

For futher As
 
首頁­常見問題­搜尋­會員列表­會員群組­會員註冊­登入
分享 | 
 

 [分享]鞍點

上一篇主題 下一篇主題 向下 
發表人內容
狂貓
Admin


文章數: 6
注冊日期: 2008-10-25

發表主題: [分享]鞍點   周六 11月 08, 2008 1:26 pm

procedure TForm1.Button1Click(Sender: TObject);
var
sum : array[1..4,1..4] of integer;
i,j,x,y,min : integer;
print : boolean;
s : string;
begin

edit1.text :='';
edit2.text :='';
memo1.clear;
randomize;
for y := 1 to 4 do
for x := 1 to 4 do
sum[x,y] := random(40)*10;

for y := 1 to 4 do
begin
for x := 1 to 4 do
if sum[x,y]>99 then s := s+' '+ inttostr(sum[x,y])
else s := s + ' '+ inttostr(sum[x,y]);
memo1.lines.add(s);
s := '';
end;

min := 1000;

for y := 1 to 4 do
begin
print := true;
for i := 1 to 4 do
if sum[i,y]< min then
begin
min := sum[i,y];
x :=i;
end;
for j := 1 to 4 do
if min <sum[x,j] then print := false;
if print then
begin
edit1.text := edit1.text +' '+ inttostr(x);
edit2.text := edit2.text +' '+ inttostr(y);
end;
min := 1000;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.text :='';
edit2.text :='';
memo1.clear;
end;

end.


可能有更好的方法...
回頂端 向下
檢視會員個人資料
Melilu



文章數: 2
注冊日期: 2008-10-25

發表主題: 回復: [分享]鞍點   周一 11月 10, 2008 7:05 pm

begin
memo1.clear;
a[1,1]:=40; a[1,2]:=20; a[1,3]:=30; a[1,4]:=10;
a[2,1]:=160; a[2,2]:=60; a[2,3]:=50; a[2,4]:=80;
a[3,1]:=100; a[3,2]:=130; a[3,3]:=110; a[3,4]:=90;
a[4,1]:=80; a[4,2]:=140; a[4,3]:=60; a[4,4]:=70;
for i:=1 to 4 do begin
s:='';
for j:=1 to 4 do
s:=s+' '+inttostr(a[i,j]);
memo1.Lines.Add(s);
end;
for i:=1 to 4 do begin
min:=a[i,1];
for x:=1 to 4 do
if a[i,x]<min then min:=a[i,x];
for j:=1 to 4 do begin
max:=a[1,j];
for y:=1 to 4 do
if a[y,j]>max then max:=a[y,j];
if max=min then
edit1.Text:=inttostr(min);
end;
end;
end;

end.
gary 版
回頂端 向下
檢視會員個人資料
 

[分享]鞍點

上一篇主題 下一篇主題 回頂端 
1頁(共1頁)

這個論壇的權限:無法 在這個版面回復文章
Get A! :: 學術討論 :: 資訊科技科-