Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- fstream input("data.txt");
- using namespace std;
- struct Point
- {
- private:
- float x;
- float y;
- public:
- Point(float a,float b)
- {
- x = a;
- y = b;
- }
- Point(){};
- float getX()const
- {
- return x;
- }
- float getY()const
- {
- return y;
- }
- void setY(float a)
- {
- x = a;
- }
- void setX(float b)
- {
- y = b;
- }
- };
- struct Segment
- {
- private:
- Point a, b;
- public:
- Segment(Point first, Point second)
- {
- a = first;
- b = second;
- }
- Segment(){};
- static float Line(Point a,Point b)
- {
- return sqrt(pow((a.getX() - b.getX()), 2) + pow((a.getX() - b.getY()), 2));
- }
- Point getFirst()const
- {
- return a;
- }
- Point getLast()const
- {
- return b;
- }
- };
- struct polygonalLine
- {
- private:
- Segment arr[20];
- int n;
- public:
- polygonalLine(Segment a[20], int m)
- {
- for (int i = 0; i < n; i++)
- {
- arr[i] = a[i];
- }
- n = m;
- }
- polygonalLine(){};
- static float polygonalLineLength(Segment *, int);
- };
- float polygonalLine::polygonalLineLength(Segment* arr, int m)
- {
- float sum = 0;
- for (int i = 0; i < m; i++)
- {
- sum = sum + Segment::Line()
- }
- }
- /*void globalDeclaration()
- {
- Point crr[20];
- Segment brr[20];
- int arr[20];
- int NUMBER = 4;
- for (int i = 0; i < NUMBER; i++)
- {
- float x,y;
- input >> x;
- crr[i].setX(x);
- input >> y;
- crr[i].setY(y);
- }
- }*/
- int main()
- {
- Point x(0, 0);
- Point y(1, 1);
- Segment line(x, y);
- float sum=Segment::Line(x, y);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement