-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.cpp
More file actions
43 lines (40 loc) · 786 Bytes
/
point.cpp
File metadata and controls
43 lines (40 loc) · 786 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
#include<iostream>
using namespace std;
class Point {
double x, y;
public:
void scan();
void print();
Point(){}
Point(double x, double y){
this->x=x;
this->y=y;
}
Point operator + (const Point &o){
Point temp;
temp.x=x+o.x;
temp.y=y+o.y;
return temp;
}
Point operator - (const Point &o){
Point temp;
temp.x=x-o.x;
temp.y=y-o.y;
return temp;
}
Point operator / (double a){
Point temp;
temp.x=x/a;
temp.y=y/a;
return temp;
}
double operator * (const Point &o){
return x*o.y-y*o.x;
}
};
void Point :: scan() {
cin >> x >> y;
}
void Point :: print() {
cout << "(" << x << "," << y << ")" << endl;
}