find the biggest variable by looping
#1

hi,

i searched first in order to solve my prob but it didnt help me tho'.
I hope someone can help me.

I have a voting system using variables:
pawn Код:
new VoteOptions[40];

//then everytime someone votes for a certain option the specific variable is increased:

    if(listitem == 0)
    {
        VoteOptions[0]++;
    }
    else if(listitem == 1)
    {
                VoteOptions[1]++;
    }
    else if(listitem == 2)
    {
        VoteOptions[2]++;
    }
        //etc. up to 39...
So how can i find the biggest variable at the end of the vote?
I tried it with looping:

pawn Код:
new biggest;
for(new i = 0; i < VoteOptions[i]; i++)
for(VoteOptions[biggest] < VoteOptions[i])//i dunno what exactly to do here...
biggest = i;

            if(biggest == VoteOptions[0])
            {
                //Do smth. when variable 1 is the biggest
            }
            else if(biggest == VoteOptions[1]
            {
                       //Do smth. when variable 2 is the biggest
            }
            else if(biggest == VoteOptions[2])
            {
                //Do smth. when variable 3 is the biggest
            }
                        //etc...
I hope you can help me (also givin reps+)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)