-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path501.cpp
More file actions
108 lines (56 loc) · 907 Bytes
/
501.cpp
File metadata and controls
108 lines (56 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>
#include <cmath>
using namespace std;
class Point {
public:
int x;
int y;
Point(int xx, int yy)
{
x = xx;
y = yy;
}
void printPoint()
{
cout << "(" << x << "," << y << ")" << endl;
}
};
class Line {
public:
Point *p1, *p2;
Line(int x1, int y1, int x2, int y2)
{
p1 = new Point(x1, y1);
p2 = new Point(x2, y2);
}
Line(const Line &line)
{
p1=new Point(line.p1->x,line.p1->y);
p2=new Point(line.p2->x,line.p2->y);
}
~Line()
{
delete p1;
delete p2;
}
void printLine()
{
p1->printPoint();
p2->printPoint();
}
};
int main()
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
Line *l1 = new Line(x1, y1, x2, y2);
Line *l2 = new Line(*l1);
l2->printLine();
l1->p1->x++;
l2->printLine();
l1->p2->y--;
l2->printLine();
delete l1;
l2->printLine();
return 0;
}