Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct rownanie
  5. {
  6. float a;
  7. float b;
  8. float c;
  9. };
  10.  
  11. int main()
  12. {
  13. struct rownanie r1;
  14. struct rownanie r2;
  15.  
  16. printf("Podaj pierwsze rownanie w formacie: Ax+By=C\nPodaj A: ");
  17. scanf("%f", &r1.a);
  18. printf("Podaj B: ");
  19. scanf("%f", &r1.b);
  20. printf("Podaj C: ");
  21. scanf("%f", &r1.c);
  22.  
  23. printf("Podaj drugie rownanie w formacie: Ax+By=C\nPodaj A: ");
  24. scanf("%f", &r2.a);
  25. printf("Podaj B: ");
  26. scanf("%f", &r2.b);
  27. printf("Podaj C: ");
  28. scanf("%f", &r2.c);
  29.  
  30. int w,wx,wy;
  31. w = r1.a*r2.b - r1.b*r2.a;
  32. wx = r1.c*r2.b - r1.b*r2.c;
  33. wy = r1.a*r2.c - r1.c*r2.a;
  34.  
  35. if(w!=0)
  36. {
  37. printf("x = %f\ny = %f", (float)wx/w, (float)wy/w);
  38. }
  39. else
  40. {
  41. if(wx==0&&wy==0)
  42. {
  43. printf("nieskonczenie wiele rozwiazan");
  44. }
  45. else
  46. printf("uklad sprzeczny");
  47. }
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement