📄 position.hpp
字号:
#ifndef POSITION_HPP
#define POSITION_HPP
#include<iostream.h>
//二维点坐标类
class Pos{
friend istream &operator>>(istream &cin,Pos &obj);
friend ostream &operator<<(ostream &cout,Pos &obj);
public:
Pos(){x=0.0;y=0.0;}
Pos(double a,double b){x=a;y=b;}
void setX(double a){x=a;}
void setY(double b){y=b;}
double getX(){return x;}
double getY(){return y;}
void setN(int n){num=n;}
int getN(){return num;}
private:
int num; //节点统一编号,用于判断节点位置
double x; //x坐标
double y; //y坐标
};
istream &operator>>(istream &cin,Pos &obj)
{
char c;
cin>>c;
cin>>obj.x>>c;
cin>>obj.y>>c;
return cin;
}
ostream &operator<<(ostream &cout,Pos &obj)
{
cout<<"("<<obj.x<<","<<obj.y<<")";
return cout;
}
#endif //POSITION_HPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -