Solved

quick and easy one..

Posted on 2004-04-09
1
139 Views
Last Modified: 2010-04-05
is there a method in delphi that returns the index of the element that holds the highest value in an array`?
0
Comment
Question by:Darth_helge
1 Comment
 
LVL 6

Accepted Solution

by:
rbohac earned 125 total points
ID: 10795800
no. You will have to loop through the entire array to find the highest value.

var x,idx,HighValue:Integer;
begin
idx := -1;
HighValue := Low(Integer);
for x:=low(myarray) to high(myarray) do
  if myarray[x] > HighValue then
    begin
      HighValue := myarray[x] ;
      idx :=x;
    end;

ShowMessage('Highest value is at index '+IntToStr(idx));
end;
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now