Advertisement
mailnesia

Untitled

May 4th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. float a(){
  5. float a;
  6. printf("Podaj wspolczynnik a: \n");
  7. scanf("%f", &a);
  8. return a;
  9. }
  10. float b(){
  11. float b;
  12. printf("Podaj wspolczynnik b: \n");
  13. scanf("%f", &b);
  14. return b;
  15. }
  16. float c(){
  17. float c;
  18. printf("Podaj wspolczynnik c: \n");
  19. scanf("%f", &c);
  20. return c;
  21. }
  22. float wyznacznik(float d, float e, float f){
  23.     float wynik;
  24. wynik=pow(e,2)-4*d*f;
  25. return wynik;
  26. }
  27. void dane (){
  28. a();
  29. b();
  30. c();
  31. }
  32. void przetworz(){
  33.     float delta,ab,bc,ce,x1,x2,x;
  34.    ab=a();
  35.     bc=b();
  36.     ce=c();
  37.  
  38.  
  39.    delta=wyznacznik(ab,bc,ce);
  40. if (delta<0)
  41.     {
  42.         printf("Rownanie nie posiada rozwiazania w zbiorze liczb rzeczywistych");
  43.     }
  44. if (delta==0)
  45.     {
  46.         x=(-bc)/2*ab;
  47.         printf("Rozwiazaniem jest X=%f",x);
  48.     }
  49. if (delta>0)
  50.     {
  51.         x1=(-bc-sqrt(delta))/2*ab;
  52.         x2=(-bc+sqrt(delta))/2*ab;
  53.         printf("Rozwiazaniem jest X1= %f lub X2= %f", x1,x2);
  54.  
  55.     }}
  56. main(){
  57.     printf("*********************** Rownania kwadratowe ***********************\n");
  58.     dane();
  59. przetworz();
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement