求助:如何比较N个数的大小
用D如何得出N个数中的最大最小值.望给出源码.我是一个初学者.谢谢.
很好解决的,给你写个例子自己看吧!
procedure TForm1.Button1Click(Sender: TObject);
var vData:array of integer;
temp:integer;
Function FindMaxValues(var vData:array of integer):integer;
var temp:integer;
begin
result:=0;
for temp:=0 to high(vData) do
if vData[temp]>result then result:=vData[temp];
end;
Function FindMinValues(var vData:array of integer):integer;
var temp:integer;
begin
result:=0;
for temp:=0 to high(vData) do
if vData[temp]<result then result:=vData[temp];
end;
begin
{定义10个数,给它赋初值,具体值自己给}
setlength(vData,10);
for temp:=0 to high(vData) do
vData[temp]:=temp;
showmessage(inttostr(FindMaxValues(vData)));
showmessage(inttostr(FindMinValues(vData)));
end;