Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #define M_PI 3.14159265358979323846
  4.  
  5. using namespace std;
  6.  
  7. class punkt {
  8. public:
  9. int x, y;
  10.  
  11. punkt() {
  12. x = 0;
  13. y = 0;
  14. }
  15.  
  16. ~punkt() {
  17. cout << "destruktor sie wywolal" << endl;
  18. }
  19.  
  20. void pobierzX() {
  21. int a;
  22. cout << "podaj X ";
  23. cin >> a;
  24. x = a;
  25. cout << endl;
  26. }
  27.  
  28. void pobierzY() {
  29. int a;
  30. cout << "podaj Y ";
  31. cin >> a;
  32. y = a;
  33. cout << endl;
  34. }
  35.  
  36. void wypisz() {
  37. cout << "wspolrzedne punktu to ( " << x << " , " << y << " )" << endl;
  38. }
  39.  
  40. };
  41.  
  42. class odcinek {
  43. public:
  44. punkt poczatek, koniec;
  45.  
  46. void dlugosc() {
  47. cout << "dlugosc odcinka wynosi " << sqrt((poczatek.x - koniec.x)*(poczatek.x - koniec.x) + (poczatek.y - koniec.y)*(poczatek.y - koniec.y)) << endl;
  48.  
  49. }
  50.  
  51. void wczytajP() {
  52. int a, b;
  53. cout << "podaj X poczatku ";
  54. cin >> a;
  55. cout << endl << "podaj Y poczatku ";
  56. cin >> b;
  57.  
  58. poczatek.x = a;
  59. poczatek.y = b;
  60.  
  61. }
  62.  
  63. void wczytajK() {
  64. int a, b;
  65. cout << "podaj X konca ";
  66. cin >> a;
  67. cout << endl << "podaj Y konca ";
  68. cin >> b;
  69.  
  70. koniec.x = a;
  71. koniec.y = b;
  72.  
  73. }
  74.  
  75.  
  76. odcinek() {
  77. poczatek.x = 0;
  78. poczatek.y = 0;
  79. koniec.x = 10;
  80. koniec.y = 10;
  81. }
  82.  
  83. ~odcinek() {
  84. cout << "destruktor sie wywolal" << endl;
  85. }
  86.  
  87. };
  88.  
  89.  
  90. class okrag {
  91. public:
  92.  
  93. friend class okrag;
  94.  
  95. static int licznik;
  96.  
  97. punkt srodek;
  98. int promien;
  99.  
  100. void wpiszS() {
  101. int a, b;
  102. cout << "podaj X srodka ";
  103. cin >> a;
  104. cout << endl << "podaj Y srodka ";
  105. cin >> b;
  106.  
  107. srodek.x = a;
  108. srodek.y = b;
  109.  
  110. }
  111.  
  112. void wpiszP() {
  113. int a;
  114. cout << "podaj promien okregu ";
  115. cin >> a;
  116. promien = a;
  117.  
  118. }
  119.  
  120.  
  121. void pole() {
  122. cout << "pole kola wynosi " << M_PI * promien*promien << endl;
  123.  
  124. }
  125.  
  126. void sprZaw(punkt p) {
  127. if (sqrt((p.x - srodek.x) * (p.x - srodek.x) + (p.y - srodek.y) * (p.y - srodek.y)) > promien) {
  128. cout << "podany punkt nie zawiera sie w okregu" << endl;
  129. }else
  130. cout << "podany punkt zawiera sie w okregu" << endl;
  131. }
  132.  
  133. void wypisz() {
  134. cout << "wspolrzedne srodka okregu to " << srodek.x << " , " << srodek.y << " a promien jest rowny " << promien << endl;
  135. }
  136.  
  137.  
  138.  
  139. okrag() {
  140. srodek.x = 0;
  141. srodek.y = 0;
  142. promien = 5;
  143. licznik++;
  144. }
  145.  
  146. ~okrag() {
  147. cout << "destruktor sie wywolal" << endl;
  148. licznik--;
  149. }
  150.  
  151.  
  152. };
  153.  
  154. void przeciecie(okrag a, okrag b) {
  155. if (sqrt((a.srodek.x - b.srodek.x) * (a.srodek.x - b.srodek.x) + (a.srodek.y - b.srodek.y) * (a.srodek.y - b.srodek.y)) == (a.promien+b.promien)) {
  156. cout << "podane okregi sa do siebie styczne " << endl;
  157. }
  158. else if(sqrt((a.srodek.x - b.srodek.x) * (a.srodek.x - b.srodek.x) + (a.srodek.y - b.srodek.y) * (a.srodek.y - b.srodek.y)) < (a.promien + b.promien))
  159. cout << "podane okregi sa rozlaczne zewnetrznie " << endl;
  160. else if (sqrt((a.srodek.x - b.srodek.x) * (a.srodek.x - b.srodek.x) + (a.srodek.y - b.srodek.y) * (a.srodek.y - b.srodek.y)) < (a.promien + b.promien))
  161. cout << "podane okregi sa rozlaczne zewnetrznie " << endl;
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. }
  169.  
  170.  
  171. int main() {
  172.  
  173.  
  174.  
  175. punkt p1;
  176. p1.wypisz();
  177. p1.pobierzX();
  178. p1.pobierzY();
  179. p1.wypisz();
  180.  
  181. okrag o1;
  182. o1.wypisz();
  183. o1.sprZaw(p1);
  184.  
  185.  
  186. system("pause");
  187. return 0;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement