zoukankan      html  css  js  c++  java
  • nyoj 101-两点距离 (数学)

    101-两点距离


    内存限制:64MB 时间限制:3000ms 特判: No
    通过数:27 提交数:74 难度:1

    题目描述:

    输入两点坐标(X1,Y1),(X2,Y2)(0<=x1,x2,y1,y2<=1000),计算并输出两点间的距离。

    输入描述:

    第一行输入一个整数n(0<n<=1000),表示有n组测试数据;
    随后每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。

    输出描述:

    对于每组输入数据,输出一行,结果保留两位小数。误差在0.01 范围内就可以通过。

    样例输入:

    2
    0 0 0 1
    0 1 1 0

    样例输出:

    1.00
    1.41

    C/C++ AC:

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <cmath>
     6 #include <stack>
     7 #include <set>
     8 #include <map>
     9 #include <queue>
    10 #include <climits>
    11 
    12 using namespace std;
    13 int N;
    14 
    15 int main()
    16 {
    17     cin >> N;
    18     while (N --)
    19     {
    20         double X1, X2, Y1,Y2;
    21         cin >> X1 >>Y1 >>X2 >>Y2;
    22 
    23         printf("%.2f
    ", sqrt((X1 - X2)*(X1 - X2) + (Y1 - Y2)*(Y1 - Y2)));
    24     }
    25 }
  • 相关阅读:
    leetcode 443: String Compression,357: Count Numbers with Unique Digits
    C++ 中 freopen()函数的用法
    filter
    map
    os.listdir
    os.path.join
    assert
    numpy中的axis和Pytorch中的dim参数
    mac中qq接收视频存放的位置
    requests
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9328436.html
Copyright © 2011-2022 走看看