美文网首页程序员交流
实验13题目1:计算两点间距离(结构体)

实验13题目1:计算两点间距离(结构体)

作者: xmmhhh33 | 来源:发表于2019-06-14 21:22 被阅读0次

#include <stdio.h>

#include <math.h>

struct point

{

    float x;

    float y;

};

int main()

{

    struct point p1,p2;

    scanf("%f%f",&p1.x,&p1.y);

    scanf("%f%f",&p2.x,&p2.y);

    float m,n,a,b,c,d;

    m=p1.x-p2.x;

    n=p1.y-p2.y;

    a=m*m;

    b=n*n;

    c=a+b;

    d=sqrt(c);

    printf("%.2f",d);

}

相关文章

网友评论

    本文标题:实验13题目1:计算两点间距离(结构体)

    本文链接:https://www.haomeiwen.com/subject/uoemfctx.html