AcWing 662. 点的坐标
原题链接
简单
作者:
Overmind
,
2021-01-29 20:17:31
,
所有人可见
,
阅读 259
#include <iostream>
using namespace std;
class point{
public:
point(double a=0,double b=0):x(a),y(b){}
void quadrant();
friend istream & operator >> (istream &,point &);
//void display(){
// cout<<x<<'\t'<<y<<endl;
//}
private:
double x;
double y;
};
void point::quadrant(){
if(x>0){
if(y>0) cout<<"Q1"<<endl;
else if(y<0) cout<<"Q4"<<endl;
else cout<<"Eixo X"<<endl;
}
else if(x<0){
if(y>0) cout<<"Q2"<<endl;
else if(y<0) cout<<"Q3"<<endl;
else cout<<"Eixo X"<<endl;
}
else {
if(y != 0) cout<<"Eixo Y"<<endl;
else cout<<"Origem"<<endl;
}
}
istream & operator >>(istream &input,point &a){
input>>a.x>>a.y;
return input;
}
int main(){
point p;
cin>>p;
//p.display();
p.quadrant();
return 0;
}