09.10.2011, 14:41
intIns
Inserts an integer to another integer and returns the final value:
Examples:
NOTE: You also need intLen which I posted here.
Inserts an integer to another integer and returns the final value:
pawn Код:
stock intIns(iNum1, iNum2, iPos)
{
static
iLength[2]
;
iLength[0] = intLen(iNum1);
iLength[1] = intLen(iNum2);
if((0 <= (iLength[0] + iLength[1]) <= 9) && (0 <= (iLength[0] -= iPos) <= 9))
{
iLength[0] = floatround(floatpower(10.0, iLength[0]));
iLength[1] = floatround(floatpower(10.0, iLength[1]));
return ((((iNum1 / iLength[0]) * iLength[1]) + iNum2) * iLength[0]) + (iNum1 % iLength[0]);
}
return 0;
}
pawn Код:
printf("%d", intIns(1245, 3, 2)); // Prints 12345
printf("%d", intIns(666666, 999, 3)); // Prints 666999666