22.02.2016, 03:00
(0 - (15 - 5) - 4) = -24.
"result" starts from zero and subtracts from there, which is the reason why you're getting -24.
To start at 15 you could do:
Outputs:
"result" starts from zero and subtracts from there, which is the reason why you're getting -24.
To start at 15 you could do:
pawn Код:
stock SubtractNumber(start, ...)
{
new result = start;
for(new i = 1, l = numargs(); i < l; ++i)
{
result = result - getarg(i);
printf("Arg %d = %d", i,getarg(i));
}
return result;
}
pawn Код:
printf("%i", SubtractNumber(15, 5, 4));
pawn Код:
6

