Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- class Point
- {
- double x, y, z;
- static int count;
- public:
- Point()
- {
- x = y = z = 0;
- count++;
- }
- Point(double x, double y, double z)
- {
- count++;
- this->x = x;
- this->y = y;
- this->z = z;
- }
- int getCount()
- {
- return count;
- }
- double range()
- {
- return sqrt(x*x + y * y + z * z);
- }
- double getX()
- {
- return x;
- }
- double getY()
- {
- return y;
- }
- double getZ()
- {
- return z;
- }
- void show()
- {
- cout << x << ' ' << y << ' ' << z << "\n\n";
- }
- bool operator < (Point & a)
- {
- return (this->range() < a.range());
- }
- };
- int Point::count = 0;
- const int MAXSIZE = 100;
- int main()
- {
- ifstream in("input.txt");
- Point a(1, 2, 4);
- Point b(2, 3, 5);
- Point c;
- a.show();
- b.show();
- c.show();
- cout << "created " << a.getCount() << " objects\n\n";
- if (a < b)
- cout << "a less than b\n\n";
- else
- cout << "a greater than b\n\n";
- cout << a.range();//расстояние от точки a до начала координат
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement