Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. float pierwiastek(a,b,c)
  4. {
  5. float delta;
  6. float pierw_delta;
  7. float x1, x2, x0;
  8. delta = b*b-4*a*c;
  9. pierw_delta = sqrt(delta);
  10. printf ("Delta: %f\n", delta);
  11.  
  12. if (delta>0){
  13.     printf("Pierwiastek z delty: %f\n",pierw_delta);
  14.     x1 = (-b-pierw_delta)/2*a;
  15.     x2 = (-b+pierw_delta)/2*a;
  16.     printf ("x1: %f\n", x1);
  17.     printf ("x2: %f\n", x2);
  18. }
  19.  
  20. if (delta == 0){
  21.     x0=-b/2*a;
  22.     printf ("x0: %f\n", x0);
  23. }
  24. if (delta<0){
  25.     printf("Brak rozwiazan\n");
  26.    
  27. }
  28.     return x0, x1, x2;
  29. }
  30.  
  31.  
  32. int main() {
  33.     pierwiastek(1,2,3);
  34.     pierwiastek (1,2,1);
  35.         return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement