【NYOJ】[101]两点距离

这里写图片描述

其实还是和杭电上的那一题一样
不过我想明白啦
不用纠结这么多
想传就传
任性╭(╯^╰)╮

#include<stdio.h>
#include<math.h>
int main() {
    int T;
    scanf("%d",&T);
    while(T--) {
        double x1,y1,x2,y2;
        scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
        printf("%.2lf
",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
    }
    return 0;
}

标程也暂时没想到什么亮点
不过就当是再欣赏欣赏C++了

#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main() {
    /*freopen("1.txt","r",stdin);
    freopen("2.txt","w",stdout);*/

    double x1,x2,y1,y2,m;
    double a;
    cin>>m;
    while(m--) {
        cin>>x1>>y1>>x2>>y2;
        a=sqrt((double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
        cout.setf(ios::fixed);
        cout<<setprecision(2)<<a<<endl;
    }
    return 0;
}

题目地址:【NYOJ】[101]两点距离

原文地址:https://www.cnblogs.com/BoilTask/p/12569851.html