Advertisement
DanGT

Equação de 2° Grau em Pawn

Nov 2nd, 2013
3,354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rexx 0.63 KB | None | 0 0
  1. stock raizdelta(a,b,c)
  2. {
  3.     new delta;
  4.  
  5.     delta = (b < 0 ? ((-b << 1)-4*a*c) : ((b << 1)-4*a*c));
  6.     printf("%dx² %dx %d\n    ? = %d² -4 x %d x %d\n    ? = %d\n        x = %d +- Raiz de %d(? = Delta) / 2 x %d", a, b, c, b, a, c, delta, b < 0 ? b*-1 : b, delta, a);
  7.        
  8.     if(delta < 0)
  9.         printf("Não existe raiz de delta negativo!");
  10.     else
  11.         for(new x = 0; x ^ delta; ++x)
  12.             if(x*x == delta)
  13.                 printf("            x' = %d+%d / 2 x %d = %d", b, x, a, (-b+x)/(2*a)),
  14.                 printf("            x'' = %d-%d / 2 x %d = %d",  b, x, a, (-b-x)/(2*a)),
  15.                 printf("                S = {%d,%d}", (-b+x)/(2*a), (-b-x)/(2*a));
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement