img

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include<iostream>
using namespace std;
class point
{
private:
    double a, b, c;
public:
    point() {}
    void set()
    {
        cin >> a >> b >> c;
    }
    point(double a1, double b1, double c1) :a(a1), b(b1), c(c1) {}
    double operator-(point& p)
    {
        return sqrt((this->a - p.a) * (this->a - p.a) + (this->b - p.b) * (this->b - p.b) + (this->c - p.c) * (this->c - p.c));
    }
};
template<class T>
double dist(T a, T b)
{
    return abs(a - b);
}
int main()
{
    int n;
    while (true)
    {
        cin >> n;
        if (n == 0)break;
        if (n == 1)
        {
            int a, b;
            cin >> a >> b;
            cout << dist(a, b) << endl;
        }
        else if (n == 2)
        {
            float a, b;
            cin >> a >> b;
            cout << dist(a, b) << endl;
        }
        else {
            point a, b;
            a.set();
            b.set();
            cout << dist(a, b) << endl;
        }
    }
}
posted on 2023-05-24 17:59  许七安gyg  阅读(1)  评论(0编辑  收藏  举报
$(document).ready(function() { // 禁止右键 $(document).bind("contextmenu", function(){return false;}); // 禁止选择 $(document).bind("selectstart", function(){return false;}); // 禁止Ctrl+C 和Ctrl+A $(document).keydown(function(event) { if ((event.ctrlKey&&event.which==67) || (event.ctrlKey&&event.which==86)) { //alert("对不起,版权所有,禁止复制"); return false; } }); });