Integer variable comparison
#1

I have a little question.


I have to compare four integer variables, and get which of them has the smallest value

pawn Code:
new variable[4];


if (variable[1] < variable[2] < variable[3] < variable[4]) //This IS NOT what I am looking for

How could I do that?
Reply
#2

pawn Code:
new variable[4];

stock WhichIsSmallest(variable1,variable2,variable3,variable4)
{
if(variable1 < variable2 && variable1 < variable3 && variable1 < variable4) return 1;
else if(variable2 < variable1 && variable2 < variable3 && variable2 < variable4) return 2;
else if(variable3 < variable1 && variable3 < variable2 && variable3 < variable4) return 3;
else return 4;

}
Reply
#3

Yea, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)