Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. class punkt
  7. {
  8. float _x;
  9. float _y;
  10. public:
  11. punkt()
  12. {
  13. _x = _y = 0;
  14. }
  15. punkt(float a, float b)
  16. {
  17. _x = a;
  18. _y = b;
  19. }
  20. float odleglosc(punkt p)
  21. {
  22. return sqrt((_x-p.x())*(_x-p.x()) + (_y-p.y())*(_y-p.y()));
  23. }
  24. float &x()
  25. {
  26. return _x;
  27. }
  28. float &y()
  29. {
  30. return _y;
  31. }
  32. };
  33.  
  34. class wielobok
  35. {
  36. punkt *_tab;
  37. int _n;
  38. public:
  39. wielobok(punkt* p, punkt *k)
  40. {
  41. _n = k-p;
  42. _tab = new punkt[_n];
  43. for(int i=0; i<_n; i++)
  44. {
  45. _tab[i] = p[i];
  46. }
  47. }
  48. };
  49.  
  50. int main()
  51. {
  52. punkt p(2, 3);
  53. cout << p.x() << " " << p.y() << "\n";
  54. p.x() = 1; p.y() = 1;
  55. cout << p.x() << " " << p.y() << "\n";
  56. cout << p.odleglosc(punkt()) << "\n";
  57.  
  58. punkt t[] = { punkt(0, 1), punkt(0, 0), punkt(1, 0), punkt(1, 1) };
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement