Home > Back-end >  - how to modify the following function, can receive not 0 the minimum??
- how to modify the following function, can receive not 0 the minimum??

Time:10-18

If a given GetMinInArray ([0,0.8, 1.2, 20]), the minimum value is 0, how to get to 0, the smallest value of 0.8, how to modify this function?

//for the minimum
The function GetMinInArray (A: an array of Integer) : Integer;
Var I: Integer;
TmpMin: Integer;
The begin
TmpMin:=A, [0].
For I:=low to High (A) (A) do
The begin
If A [I] end;
Result:=tmpMin;
end;

CodePudding user response:

Correct under the above function that returns the type double
The function GetMinInArray (A: an array of double) : double;
Var I: Integer;
TmpMin: double;
The begin
TmpMin:=A, [0].
For I:=low to High (A) (A) do
The begin
If A [I] end;
Result:=tmpMin;
end;

CodePudding user response:

 
The function GetMinInArray (A: an array of double) : double;
Var I: Integer;
TmpMin: double;
The begin
TmpMin:=A, [0].
For I:=low to High (A) (A) do
The begin
If (A [I] <> 0) and (A [I] end;
Result:=tmpMin;
end;


 
The function GetMinInArray (A: an array of double) : double;
Var I: Integer;
TmpMin: double;
The begin
TmpMin:=A, [0].
For I:=low to High (A) (A) do
The begin
If (A [I] & gt; 0) and (A [I] end;
Result:=tmpMin;
end;

CodePudding user response:

LZ is too fixed mind, don't turn the,
Even you know how to use more sorting method for screening the minimum, that when you compare condition does not have to add a not 0

CodePudding user response:

CodePudding user response:

0.8 smaller than 0?
  • Related