Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class punkt
- {
- float _x;
- float _y;
- public:
- punkt()
- {
- _x = _y = 0;
- }
- punkt(float a, float b)
- {
- _x = a;
- _y = b;
- }
- float odleglosc(punkt p)
- {
- return sqrt((_x-p.x())*(_x-p.x()) + (_y-p.y())*(_y-p.y()));
- }
- float &x()
- {
- return _x;
- }
- float &y()
- {
- return _y;
- }
- };
- class wielobok
- {
- punkt *_tab;
- int _n;
- public:
- wielobok(punkt* p, punkt *k)
- {
- _n = k-p;
- _tab = new punkt[_n];
- for(int i=0; i<_n; i++)
- {
- _tab[i] = p[i];
- }
- }
- };
- int main()
- {
- punkt p(2, 3);
- cout << p.x() << " " << p.y() << "\n";
- p.x() = 1; p.y() = 1;
- cout << p.x() << " " << p.y() << "\n";
- cout << p.odleglosc(punkt()) << "\n";
- punkt t[] = { punkt(0, 1), punkt(0, 0), punkt(1, 0), punkt(1, 1) };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement