球对称中心

/*
* 程序的版权和版本声明部分
* Copyright (c)2013, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: fibnacci.cpp
* 作    者:高古尊
* 完成日期:2014年2月27日
* 版本号: v1.0
*
* 输入描述:
* 问题描述:
* 程序输出:
* 问题分析:
*/
#include <iostream>
#include <math.h>
using namespace std;
struct Point
{
    double x; //横坐标
    double y; // 纵坐标
};
enum SymmetricStyle {axisx,axisy,point};//分别表示按x轴,y轴,原点对称
double distance(Point,Point); //两点之间的距离
double distance0(Point );
Point symmetricAxis(Point,SymmetricStyle); //返回对称点
int main( )
{
    Point p1={1,5},p2={4,1},p;
    cout<<"两点的距离为:"<<distance(p1,p2)<<endl;
    cout<<"p1到原点的距离为:"<<distance0(p1)<<endl;
    p=symmetricAxis(p1,axisx);
    cout<<"p1关于x轴的对称点为:"<<"("<<p.x<<", "<<p.y<<")"<<endl;
    p=symmetricAxis(p1,axisy);
    cout<<"p1关于y轴的对称点为:"<<"("<<p.x<<", "<<p.y<<")"<<endl;
    p=symmetricAxis(p1,point);
    cout<<"p1关于原点的对称点为:"<<"("<<p.x<<", "<<p.y<<")"<<endl;
    return 0;
}
//求两点之间的距离
double distance(Point p1,Point p2)
{
    double d;
    d=pow((p1.x-p2.x),2)+pow((p1.y-p2.y),2);
    return sqrt(d);
}
//求点到原点的距离
double distance0(Point p)
{
    double d;
    d=pow(p.x,2)+pow(p.x,2);
    return sqrt(d);
}
//求对称点
Point symmetricAxis(Point p1,SymmetricStyle style)
{
    Point p;
    switch(style)
    {
    case axisx:
        p.x=p1.x;
        p.y=0;
        break;
    case axisy:
        p.x=0;
        p.y=p1.y;
        break;
    case point:
        p.x=0;
        p.y=0;
        break;
    default:
        cout<<"stymer eorr!";
    }
    return p;
}


在codeblocke上无法运行,可在vc++6.0上运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值