/*
* 程序的版权和版本声明部分:
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作 者:任子仪
* 完成日期:2014年 5月 20日
* 版 本 号:v12.1
* 输入描述:无
* 问题描述:。
* 程序输出:
* 问题分析:略
* 算法设计:略
*/
#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()
{
cin>>x1>>y1>>x2>>y2;
}
void output(Point&a)
{
double s;
s=sqrt((a.x1-a.x2)*(a.x1-a.x2)+(a.y1-a.y2)*(a.y1-a.y2));
cout<<" There are "<<setiosflags(ios::fixed)<<setprecision(2)<<s<<" meters between xiaohui and her phone.";
}
int main()
{
Point p1;
p1.input();
output(p1);
return 0;
}
示例图片:
心得体会:对于这道题我就想说实在不难,但那个小数点后 两位实在是太气人了。。。。我在oj平台上交了两次都错了。实在想放弃了。看到对的那一刻,高兴死我了