Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. char a = 'y';
  8.  
  9.  
  10. int i = 0, d =0 ;
  11. float x1 = 0, x2 = 0, x3 = 0;
  12. int tab[2]={0};
  13. do{
  14. printf("Podaj wspolczynniki a,b i c trojmianu kwadratowego po spacji:");
  15. for(i = 0;i<3;i++)
  16. {
  17. scanf("%d", &tab[i]);
  18. }
  19.  
  20. d=pow(tab[1],2)-4*tab[0]*tab[2];
  21. if(d>0)
  22. {
  23. x1=(-tab[1]-sqrt(d))/(2*tab[0]);
  24. x2=(-tab[1]+sqrt(d))/(2*tab[0]);
  25. printf("X1: %f X2: %f", x1, x2);
  26. }
  27. else if(d==0)
  28. {
  29. x3 = (-tab[1])/(2*tab[0]);
  30. printf("X1 = X2 = %f", x3);
  31. }
  32. else printf("brak rozwiazan");
  33.  
  34. printf("\nPonowic?(y,n)?:");
  35. scanf("%c", &a);
  36.  
  37. }while(a=='y');
  38. return 0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement