Ellipsis operator (...)
#1

Am I doing this right? xD

pawn Код:
stock MultiplyNumber(...)
    {
        new result = 0;
        for(new i = 0; i < numargs(); ++i)
        {
            result *= getarg(i);
        }
        return result;
    }
   
    stock DivideNumber(...)
    {
        new result = 0;
        for(new i = 0; i < numargs(); ++i)
        {
            result /= getarg(i);
        }
        return result;
    }
   
    stock SubtractNumber(...)
    {
        new result = 0;
        for(new i = 0; i < numargs(); ++i)
        {
            result -= getarg(i);
        }
        return result;
    }
Reply
#2

Anyone?
Reply
#3

You should first get an arg if you use multiplication or division otherwise it is just (0 * x or 0 / x)

For subtracting and addition they are both the same just the first as a minus in front of it

Just test your code and you will see if it worked

Eventhough I don't see any use of variadic parameters because each only need two, even if they are just test functions
Reply
#4

Alright, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)