阅读背景:

OJ-练习-手机找回

来源:互联网 
/*
 * Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作    者: 霍雨佳
* 完成日期:2014 年5月20日
* 版 本 号:v1.0
* 问题描述:求两坐标间的距离
* 样例输入:
* 样例输出:
* 问题分析:。
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
class Point
{
public:
    Point(double a=0,double b=0,double c=0,double d=0):x1(a),y1(b),x2(c),y2(d) {}
    void  input();
    friend void output(Point &);
private:
    double x1;
    double y1;
    double x2;
    double y2;
};
void  Point::input()
{
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    x1=a;
    y1=b;
    x2=c;
    y2=d;
}
void output(Point &p)
{
    double l;
    l=sqrt(((p.x1-p.x2)*(p.x1-p.x2))+(p.y1-p.y2)*(p.y1-p.y2));
    cout<<setiosflags(ios::fixed)<<setprecision(2);
    cout<<"There are "<<l<<" meters between xiaohui and her phone."<<endl;
}
int main()
{
    Point p1;
    p1.input();
    output(p1);
    return 0;
}
/*
 * Copyright (c) 2013, 烟台大学计算机学院
* All right



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: