19.10.2011, 16:26
Quote:
Any invalid skin ID becomes the CJ skin. |
--
Prime factor
pawn Код:
stock factor(number, aVals[])
{
new iIdx = 0, iNum = number;
for (new i = 2; i <= iNum; i++)
{
if (iNum % i == 0)
{
aVals[iIdx++] = i;
iNum = iNum / i;
i = 1;
}
}
return aVals;
}
pawn Код:
YCMD:factor(playerid, params[], help)
{
new szStr[128], szTemp[128], iTemp[12], iNumbar, aValues[32], i;
if (help) return SendClientMessage(playerid, -1, "* This function prints the prime factor of the given number.");
if (sscanf(params, "d", iNumbar)) return SendClientMessage(playerid, 0xff0000ff, "* Usage: /factor [number]");
factor(iNumbar, aValues);
valstr(iTemp, aValues[i++]);
strcat(szTemp, iTemp);
iTemp[0] = 0;
while (aValues[i])
{
valstr(iTemp, aValues[i++]);
strcat(szTemp, " * ");
strcat(szTemp, iTemp);
iTemp[0] = 0;
}
format(szStr, sizeof szStr, "* [Prime Factor] %d = %s", iNumbar, szTemp);
SendClientMessage(playerid, -1, szStr);
return 1;
}
Quote:
* [Prime Factor] 841548 = 2 * 2 * 3 * 19 * 3691 |