Advertisement
Guest User

lol

a guest
Mar 29th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6.  
  7. int main(int argc, char *argv[]) {
  8. double a,b,c,x1,x2,x,delta,spr1,spr2;
  9. int k;
  10. while(1)
  11. {
  12.  
  13. do
  14. {
  15. printf("\n POdaj a");
  16. k=scanf("%lf",&a);
  17. if(k==0) printf("\n Blad formatu");
  18. fflush(stdin);
  19. }
  20. while(k==0);
  21. do
  22. {
  23. printf("\n POdaj b");
  24. k=scanf("%lf",&b);
  25. if(k==0) printf("\n Blad formatu");
  26. fflush(stdin);
  27. }
  28. while(k==0);
  29. do
  30. {
  31. printf("\n POdaj c");
  32. k=scanf("%lf",&c);
  33. if(k==0) printf("\n Blad formatu");
  34. fflush(stdin);
  35. }
  36. while(k==0);
  37.  
  38. if(a==0)
  39. {
  40. if(b==0&&c==0)printf("\n Tozsamosc");
  41. if(b==0&&c!=0) printf("\n Sprzecznosc");
  42. if(b!=0&&c!=0) printf("\n Rownanie liniowe");
  43. {
  44. x=-b/c;
  45. printf("\n Rownanie liniowe wynosi %f",x);
  46. }
  47. }
  48. if(a!=0)
  49. {
  50. delta=b*b-(4*a*c);
  51. printf("\n delta wynosi %f",delta);
  52.  
  53. if(delta==0);
  54. {
  55. printf("\n Pierwiastek podwojny");
  56. x=-b/(2*a);
  57. printf("\n Wynosi %f",x);
  58.  
  59. }
  60. if(delta>0)
  61. {
  62. printf("\n Dwa pierwiastki");
  63. x1=(-b+sqrt(delta))/(2*a);
  64. x2=(-b-sqrt(delta))/(2*a);
  65. printf("\n x1=%f, x2=%f",x1,x2);
  66. spr1=a*x1*x1+b*x1+c;
  67. spr2=a*x2*x2+b*x2+c;
  68. printf("sprawdzenia %f i %f",spr1,spr2);
  69. }
  70. if(delta<0)
  71. {
  72. printf("\n masz przerabane");
  73. }
  74. }
  75. getch();
  76. }
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement