Advertisement
Guest User

pooooo

a guest
Apr 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 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 odcinek;
  94.  
  95. 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. }
  130. else
  131. cout << "podany punkt zawiera sie w okregu" << endl;
  132. }
  133.  
  134. void wypisz() {
  135. cout << "wspolrzedne srodka okregu to " << srodek.x << " , " << srodek.y << " a promien jest rowny " << promien << endl;
  136. }
  137.  
  138.  
  139.  
  140. okrag() {
  141. srodek.x = 0;
  142. srodek.y = 0;
  143. promien = 5;
  144. licznik++;
  145. }
  146.  
  147. ~okrag() {
  148. cout << "destruktor sie wywolal" << endl;
  149. licznik--;
  150. }
  151.  
  152.  
  153. };
  154.  
  155. void przeciecie(okrag a, okrag b) {
  156. 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)) {
  157. cout << "podane okregi sa do siebie styczne " << endl;
  158. }
  159. 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))
  160. cout << "podane okregi sa rozlaczne zewnetrznie " << endl;
  161. 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))
  162. cout << "podane okregi sa rozlaczne zewnetrznie " << endl;
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. }
  170.  
  171.  
  172. int main() {
  173.  
  174.  
  175.  
  176. punkt p1;
  177. p1.wypisz();
  178. p1.pobierzX();
  179. p1.pobierzY();
  180. p1.wypisz();
  181.  
  182. okrag o1;
  183. o1.wypisz();
  184. o1.sprZaw(p1);
  185.  
  186.  
  187. system("pause");
  188. return 0;
  189. }
  190.  
  191. /*
  192. #include <iostream>
  193. #include <string>
  194.  
  195. using namespace std;
  196.  
  197. class Kalendarz{
  198. public:
  199.  
  200. int day, month, year;
  201.  
  202. void wpisz() {
  203. cout << "podaj dzien " << endl;
  204. cin >> day;
  205. cout << "podaj miesiac " << endl;
  206. cin >> month;
  207. cout << "podaj rok " << endl;
  208. cin >> year;
  209.  
  210. }
  211.  
  212. Kalendarz& operator++() {
  213. ++day;
  214. return *this;
  215. }
  216.  
  217. Kalendarz& operator--() {
  218. --day;
  219. return *this;
  220. }
  221.  
  222.  
  223. Kalendarz() {
  224. day = 1;
  225. month = 1;
  226. year = 2000;
  227.  
  228. }
  229.  
  230. ~Kalendarz() {
  231. }
  232.  
  233. };
  234.  
  235.  
  236. Kalendarz operator>(Kalendarz d1, Kalendarz d2) {
  237. if (d1.year > d2.year) {
  238. return d1;
  239. }
  240. else if (d1.year < d2.year) {
  241. return d2;
  242. }
  243. else if (d1.month > d2.month) {
  244. return d1;
  245. }
  246. else if (d1.month < d2.month) {
  247. return d2;
  248. }
  249. else if (d1.day > d2.day) {
  250. return d1;
  251. }
  252. else if (d1.day < d2.day) {
  253. return d2;
  254. }
  255. else {
  256. cout << " podano identyczne daty " << endl;
  257. }
  258. }
  259.  
  260.  
  261. ostream& operator<<(ostream& stm,Kalendarz qq) {
  262. stm << "dzien= " << qq.day << " miesiac= " << qq.month << " rok= " << qq.year << endl;
  263. return stm;
  264. }
  265.  
  266. int main() {
  267.  
  268. Kalendarz d1,d2,d3;
  269. cout << d1;
  270. d2.wpisz();
  271. cout << d2;
  272. ++d2;
  273. cout << d2;
  274. --d2;
  275. cout << d2;
  276. d3 = d1 > d2;
  277. cout << "pozniejsza jest data " << d3 ;
  278.  
  279.  
  280.  
  281. system("pause");
  282. return 0;
  283. }
  284. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement