【项目1 - 用枚举表示对称方式】设计函数,可以按指定的方式,输出一个平面点的对称点
#include<iostream>
using namespace std;
enum SymmetricStyle {axisx, axisy, point};//分别表示按x轴, y轴, 原点对称三种方式
void output(double,double,SymmetricStyle);
int main()
{
int x,y;
cout<<"输入点的坐标:";
cin>>x>>y;
cout<<"关于x轴的对称点是:";
output(x,y,axisx);
cout<<"关于y轴的对称点是:";
output(x,y,axisy);
cout<<"关于坐标原点的对称点是:";
output(x,y,point);
return 0;
}
void output(double x,double y,SymmetricStyle m)
{
switch(m)
{
case axisx:
cout<<"("<<x<<","<<(-y)<<")"<<endl;break;
case axisy:
cout<<"("<<(-x)<<","<<y<<")"<<endl;break;
case point:
cout<<"("<<(-x)<<","<<(-y)<<")"<<endl;break;
}
}