Home > Back-end >  About to extract the maximum of an array
About to extract the maximum of an array

Time:03-24

Under the best said feeling a bit don't come here just learning thinking small white a

Topic is
Use methods to achieve: have an array of strings: {" Malone ", "Michael Jordan", "ray," Jimmy, "Tim Duncan," kobe Bryant "}, please output the longest string,

CodePudding user response:

The method of preliminary simple:

According to the circular array length, the length of each subscript data, then compare:
Const
CStr: TArray=[' Malone ', 'Michael Jordan', 'ray props',' Tim Duncan, "kobe Bryant"].
Var
I, Y: integer;

VLen:=0;
Y:=1;
If I=0 to Length (cStr) then
The begin
If vLenThe begin
VLen:=Length (cStr [I]);
Y:=I;
end;

end;

Finally vLen is the longest of the length of the string, yy is the longest string of subscript, cStr [y] is the longest string of contents of the string
  • Related