#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
class point{
public:
int x,y;
point(){
x = 0,y = 0;
}
point(int xx,int yy){
x = xx;y = yy;
}
double mod(){//向量的膜
return sqrt(x*x+y*y);
}
friend istream& operator >> (istream &,point &);
friend ostream& operator << (ostream &,point );
point operator + (point A);
point operator - (point A);
ll operator * (point A);
bool operator == (point A);
};
istream & operator >> (istream &input,point &A){
input >> A.x >> A.y;
return input;
}
ostream & operator << (ostream &output,point A){
output << A.x << " " << A.y;
return output;
}
point point::operator + (point A){
point C;
C.x = x + A.x;C.y = y + A.y;
return C;
}
point point::operator - (point A){
point C;
C.x = x - A.x;C.y = y - A.y;
return C;
}
ll point::operator * (point A){
return x*A.x + y*A.y;
}
bool point::operator == (point A){
if(x == A.x && y == A.y)
return true;
return false;
}
int main(void){
point x,y,z;
cin >> x;
cout << x.mod() << endl;
return 0;
}
重载的可加减乘的点(向量)模板
最新推荐文章于 2021-09-26 16:14:41 发布