Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. fstream input("data.txt");
  4. using namespace std;
  5. struct Point
  6. {
  7. private:
  8.     float x;
  9.     float y;
  10. public:
  11.     Point(float a,float b)
  12.     {
  13.         x = a;
  14.         y = b;
  15.     }
  16.     Point(){};
  17.     float getX()const
  18.     {
  19.         return x;
  20.     }
  21.     float getY()const
  22.     {
  23.         return y;
  24.     }
  25.     void setY(float a)
  26.     {
  27.         x = a;
  28.     }
  29.     void setX(float b)
  30.     {
  31.         y = b;
  32.     }
  33. };
  34.  
  35.  
  36. struct Segment
  37. {
  38. private:
  39.     Point a, b;
  40. public:
  41.     Segment(Point first, Point second)
  42.     {
  43.         a = first;
  44.         b = second;
  45.     }
  46.     Segment(){};
  47.     static float Line(Point a,Point b)
  48.     {
  49.         return sqrt(pow((a.getX() - b.getX()), 2) + pow((a.getX() - b.getY()), 2));
  50.     }
  51.     Point getFirst()const
  52.     {
  53.         return a;
  54.     }
  55.     Point getLast()const
  56.     {
  57.         return b;
  58.     }
  59. };
  60.  
  61.  
  62. struct polygonalLine
  63. {
  64. private:
  65.     Segment arr[20];
  66.     int n;
  67. public:
  68.     polygonalLine(Segment a[20], int m)
  69.     {
  70.         for (int i = 0; i < n; i++)
  71.         {
  72.             arr[i] = a[i];
  73.         }
  74.         n = m;
  75.     }
  76.     polygonalLine(){};
  77.     static float polygonalLineLength(Segment *, int);
  78.    
  79. };
  80. float polygonalLine::polygonalLineLength(Segment* arr, int m)
  81. {
  82.     float sum = 0;
  83.     for (int i = 0; i < m; i++)
  84.     {
  85.         sum = sum + Segment::Line()
  86.     }
  87. }
  88.  
  89. /*void globalDeclaration()
  90. {
  91.     Point crr[20];
  92.     Segment brr[20];
  93.     int arr[20];
  94.     int NUMBER = 4;
  95.     for (int i = 0; i < NUMBER; i++)
  96.     {
  97.         float x,y;
  98.         input >> x;
  99.         crr[i].setX(x);
  100.         input >> y;
  101.         crr[i].setY(y);
  102.     }
  103. }*/
  104. int main()
  105. {
  106.     Point x(0, 0);
  107.     Point y(1, 1);
  108.     Segment line(x, y);
  109.     float sum=Segment::Line(x, y);
  110.     system("pause");
  111.     return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement