zoukankan      html  css  js  c++  java
  • 问题一百三十七:计算坐标上两点之间的距离

    
    
    
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    float distance(int a, int b, int c, int d);
    
    int main(int argc, char *argv[])
    {
          int a;
          int b;
          int c;
          int d;
          
          printf("Please enter the first coordinate points x:");     //输入第一个点 
          scanf("%d %d", &a, &b);
          printf("Please enter the second coordinate points y:");    //输入第二个点
          scanf("%d %d", &c, &d);
          
          printf("The distance between two points is %f\n", distance(a, b, c, d));
          
          system("PAUSE");	
          return 0;
    }
    
    // Calculate distances
    
    float distance(int a, int b, int c, int d)     //计算两点的距离 
    {
          int   x;
          int   y;
          float distance;
          
          x=abs(a-c);
          y=abs(b-d);
          distance=sqrt(x*x+ y*y);     
          
          return distance;
    }



  • 相关阅读:
    基于JavaMail开发邮件发送器工具类
    微服务架构
    图像识别
    Manacher
    左偏树
    虚树
    动态树(Link-Cut Tree)
    Splay
    扩展中国剩余定理(EXCRT)
    K-D树
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3078501.html
Copyright © 2011-2022 走看看