Largest in array?

Status
Not open for further replies.

Summoned

New Member
Reaction score
51
If it's integers or reals, you'll want 2 variables, one for the value and one for the array index:

Basically (not going to write this out in GUI):

set value to 0
set index to 0

For Integer A from 1 - (however many you have, just keep an integer variable to count it beforehand):

if ArrayName[Integer A] > value
set value to ArrayName[Integer A]
set index to Integer A

Then at the end, value will be the highest value and index will be what number in the array it is.
 

Sevion

The DIY Ninja
Reaction score
413
No. Array size would be:

ARRAY[->SIZE<-]

The value is what ARRAY[NUMBER] equals.

So, ARRAY[5] could equal 25 or something.
 

cleeezzz

The Undead Ranger.
Reaction score
268
hes asking, if he set numbers in an integer/real array, how can he get the array number with the biggest value.

not the max array size
 
Reaction score
149
Code:
For each (Integer A) from 1 to <Your array size>, do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Array[Array_num] Less than or equal to Array[(Integer A)]
            Then - Actions
                Set Array_num = (Integer A)
                Set Array_val = Array[(Integer A)]
            Else - Actions

Array - Integer array variable
Array_num - Integer variable
Array_val - Integer variable
 

Rainther

I guess I should write something of value here...
Reaction score
61
JASS:
local integer i = 0
loop
exitwhen array<i> == null
set i = i + 1
endloop
set i = i - 1</i>
Would do the trick if you've putten a variable in each one up to the highest one.
 

DrStyles

New Member
Reaction score
7

But, GUI is better. (Cause Jass isn't working now ^.^) Ok ya sry I shoulda used the search, but I still don't get it.

Trigger:
  • Actions
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CounterKills[Array_num] Less than or equal to CounterKills[(Integer A)]
          • Then - Actions
            • Set Array_val = (Integer A)
          • Else - Actions


So, how does that get me what array number it was? I need to know what number, and how much. Can you give me an example of how I would use this to display what number in the array and what the value was?
 

cleeezzz

The Undead Ranger.
Reaction score
268
Trigger:
  • Actions
    • Set LargestValue = -100000
    • Set LargestArray = 0
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • LargestValue Less than or equal to CounterKills[(Integer A)]
          • Then - Actions
            • Set LargestArray = Integer A
            • Set LargestValue = CounterKills[Integer A]
          • Else - Actions
    • Game - Display Text to All Players (&quot;Largest Array: &quot; and Convert Integer to String (Largest Array))
    • Game - Display Text to All Players (&quot;Largest Value: &quot; and Convert Integer to String (Largest Value))
 

Sevion

The DIY Ninja
Reaction score
413
But, GUI is better. (Cause Jass isn't working now ^.^) Ok ya sry I shoulda used the search, but I still don't get it.

Wrong on so many levels.

JASS works fine. As does vJASS. It's just that people have to fix the return bug in their systems/maps/whatever that use it. And the false-positives.
 

DrStyles

New Member
Reaction score
7
Wrong on so many levels.

JASS works fine. As does vJASS. It's just that people have to fix the return bug in their systems/maps/whatever that use it. And the false-positives.

I'm not wrong in the least. Make a map in Jass and watch. In two weeks Blizzard will come out with a new patch disabling every map in Jass except DoTA. You will need to constantly fix random stuff in your code, and Blizzard will continue to ruin the game.

And no that doesn't answer my question.

I'm trying what cleeezzz said for now. There has to be an easier way...
And I'm guessing this will find the lowest number as well? So long as I put Greater or equal as opposed to Less than or equal. yes/no?
Btw what if I want to do something to all numbers in an array, then get the largest? For example, If I had 2 arrays, and I wanted to take every value from the first array and divide it by the corresponding value of the other array, and then get the largest number?
 

Sevion

The DIY Ninja
Reaction score
413
I need you to tell me how GUI is better than (v)JASS. Seriously.

There is no easier way.

You have to loop it and check.

Just do a loop. Divide Array[Integer A] by Array2[Integer A].

Then do loop and check.
 

DrStyles

New Member
Reaction score
7
I need you to tell me how GUI is better than (v)JASS. Seriously.
You do? OK. GUI > JASS
Happy? (Btw im not saying gui is better. read again.)

Just do a loop. Divide Array[Integer A] by Array2[Integer A].

Is that a condition? If Divide Array[Integer A] by Array2[Integer A] is less than equal to.. then..?
 

cleeezzz

The Undead Ranger.
Reaction score
268
no, loop through it

Trigger:
  • Actions
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • Set Array3[(Integer A)] = (Array1[(Integer A)] / Array2[(Integer A)])


then do the check for Array3
 

DrStyles

New Member
Reaction score
7
And I'm guessing this will find the lowest number as well? So long as I put Greater or equal as opposed to Less than or equal. yes/no?

So i'm guessing no then? How would i do that? What if there are more then one lowest values?
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top