27.10.2013, 14:59
pawn Код:
stock ABC_CalcularX(a, b, c) {
static delta, raiz, solucao[3];
a = a ^ 0 ? a : 1;
b = b ^ 0 ? b : 1;
c = c ^ 0 ? c : 1;
if(a < 0 || c < 0)
delta = b*b - 4*a*c*-1;
else
delta = b*b - 4*a*c;
for(new i = 0; i < delta; ++i)
{
if(i*i == delta)
{
raiz = i;
i = delta;
}
}
solucao[1] = delta + raiz / (2*a);
solucao[2] = delta - raiz / (2*a);
new result[128];
format(result, sizeof(result), "$ = {%d, %d}", solucao[1], solucao[2]);
return result;
}