What's the quickest way to find the maximum of

Thread: What's the quickest way to find the maximum of

1. Senior Member
Join Date
Dec 1969
Posts
745

What's the quickest way to find the maximum of

Hey there people,<BR><BR>What may I ask is the quickest way to determine which of several numbers is the greatest ? <BR><BR>let&#039s pretend i had values assigned to variables<BR>a,b,c,d,e,f etc<BR><BR>what&#039s the quickest way to determine which of those variables contain the largest variable using VBScript in the ASP environment.<BR><BR>michael

2. Senior Member
Join Date
Dec 1969
Posts
2,849

RE: What's the quickest way to find the maximu

This really isn&#039t a database question. You have to look at each element to determine which is the greatest. If you had an array of values, you could use the following greedy algorithm:<BR><BR>Dim iMax, iLoop<BR>iMax = LowLowValue &#039if all of your numbers are greater than or equal to 0, set iMax to 0 initially<BR><BR>For iLoop = LBound(array) to UBound(array)<BR><BR>if iMax &#062; array(iLoop) then iMax = array(iLoop)<BR><BR>Next<BR><BR>at the end of this loop, iMax will contain the greatest value in the array. If you have a fixed # of variables (say N variables), you can perform N-1 IF statements to find the least value variable...<BR><BR>Happy Programming!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•