HDU 2001 计算两点间的距离

Problem Description

输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

Input

输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。

Output

对于每组输入数据,输出一行,结果保留两位小数。

Sample Input

0 0 0 1

0 1 1 0

Sample Output

1.00

1.41

题意:输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

#include <stdio.h>
#include <math.h>
int main()
{
    double a, b, c, d, s;
    while (scanf ("%lf%lf%lf%lf", &a, &b, &c, &d)!=EOF)
    {
        s = sqrt((c-a)*(c-a)+(d-b)*(d-b));
        printf ("%.2lf\n", s);
        }
    return 0;
 }
时间: 2024-08-27 16:35:16

HDU 2001 计算两点间的距离的相关文章

HDOJ 2001 计算两点间的距离

计算两点间的距离 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 94573    Accepted Submission(s): 36296 Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y

2001 计算两点间的距离

#include<iostream> #include<cstdio> using namespace std; int main() { double a, b, x, y; while (cin >> a && cin >> b && cin >> x && cin >> y) { double ans = sqrt((x - a)*(x - a) + (y - b)*(y - b)

计算两点间的距离

计算两点间的距离 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 208295    Accepted Submission(s): 72641 Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y

ios根据gps坐标来计算两点间的距离

//ios根据gps坐标来计算两点间的距离 //x1,y1 点1的坐标 x2,y2点2的坐标 -(double) gps2m:(double)x1 _y1:(double)y1 _x2:(double)x2 _y2:(double)y2{ double radLat1 = (x1 * 3.1416 / 180.0); double radLat2 = (x2 * 3.1416 / 180.0); double a = radLat1 - radLat2; double b = (y1 - y2)

C++刷题——1924: 计算两点间的距离

1924: 计算两点间的距离 Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开. Output 对于每组输入数据,输出一行,结果保留两位小数. /* Copyright (c) 2014, 烟台大学计算机学院 * All rights reserved. * 文件名称:test.cpp * 作者:陈丹妮 * 完成日期:2015年 5 月 20 日

计算两点间的距离,hdu-2001

计算两点间的距离 Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开. Output 对于每组输入数据,输出一行,结果保留两位小数. Sample Input 0 0 0 1 0 1 1 0 Sample Output 1.00 1.41 1 #include<stdio.h> 2 #include<stdlib.h>

hdu2001 计算两点间的距离【C++】

计算两点间的距离 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 254764    Accepted Submission(s): 88773 Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y

计算两点间的距离-hdu2001

Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开. Output 对于每组输入数据,输出一行,结果保留两位小数. Sample Input 0 0 0 1 0 1 1 0 Sample Output 1.00 1.41 1 #include<stdio.h> 2 #include<math.h> 3 int main

根据经纬度计算两点间的距离

地球是一个近乎标准的椭球体,它的赤道半径为6378.140千米,极半径为 6356.755千米,平均半径6371.004千米.如果我们假设地球是一个完美的球体,那么它的半径就是地球的平均半径,记为R.如果以0度经线为基 准,那么根据地球表面任意两点的经纬度就可以计算出这两点间的地表距离(这里忽略地球表面地形对计算带来的误差,仅仅是理论上的估算值).设第一点A的经 纬度为(LonA, LatA),第二点B的经纬度为(LonB, LatB),按照0度经线的基准,东经取经度的正值(Longitude)