I need some help. I have to create a function that will calculate the distance between points (x1,y1) and (x2, y2). All numbers are of type double. I keep getting incorrect output. I am usinge visual studio and C language. Here is my code.

#include <stdio.h>
#include <math.h> double calculate_distance (double x1,double y1,double x2 ,double y2) { double distance; double distance_x = x1-x2; double distance_y = y1- y2; distance = sqrt( (distance_x * distance_x) + (distance_y * distance_y)); return distance; } int main ()
{
double x1; double x2; double y1; double y2; printf ("Let me help you find the distance between two points (x1,y1) and (x2, y2)."); printf ("\n\nEnter coordinate for x1:");
scanf ("%f", &x1); printf ("\nEnter coordinate for y1:");
scanf ("%f", &y1); printf ("\nEnter coordinate for x2:");
scanf ("%f", &x2); printf ("\nEnter coordinate for y2:");
scanf ("%f", &y2); printf ("The distance between (%f,%f) and (%f,%f) is %.2f\n\n", x1,y1,x2,y2, calculate_distance(x1,y1,x2,y2)); return ; }

Distance Between Points的更多相关文章

  1. 【BZOJ】3053: The Closest M Points(kdtree)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3053 本来是1a的QAQ.... 没看到有多组数据啊.....斯巴达!!!!!!!!!!!!!!!! ...

  2. 数据结构(KD树):HDU 4347 The Closest M Points

    The Closest M Points Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 98304/98304 K (Java/Ot ...

  3. HDU 4347 - The Closest M Points - [KDTree模板题]

    本文参考: https://www.cnblogs.com/GerynOhenz/p/8727415.html kuangbin的ACM模板(新) 题目链接:http://acm.hdu.edu.cn ...

  4. The Closest M Points

    The Closest M Points http://acm.hdu.edu.cn/showproblem.php?pid=4347 参考博客:https://blog.csdn.net/acdre ...

  5. 【BZOJ】【3053】The Closest M Points

    KD-Tree 题目大意:K维空间内,与给定点欧几里得距离最近的 m 个点. KD树啊……还能怎样啊……然而扩展到k维其实并没多么复杂?除了我已经脑补不出建树过程……不过代码好像变化不大>_&g ...

  6. BZOJ 3053: The Closest M Points(K-D Tree)

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1235  Solved: 418[Submit][Status][Discuss] Descripti ...

  7. BZOJ3053:The Closest M Points(K-D Teee)

    Description The course of Software Design and Development Practice is objectionable. ZLC is facing a ...

  8. Geographical distance

    Introduction Calculating the distance between geographical coordinates is based on some level of abs ...

  9. 【35.43%】【hdu 4347】The Closest M Points

    Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 98304/98304 K (Java/Others) Total Submissio ...

随机推荐

  1. web 前端常用组件【04】Datetimepicker 和 Lodop

    web项目中日期选择器和打印这两个功能是非常常见,将使用过的日期和打印控件,在这里总结归纳,为方便后面使用. 1.Datetimepicker a.官方API:http://www.bootcss.c ...

  2. (转)RSA算法原理(二)

      作者: 阮一峰 日期: 2013年7月 4日 上一次,我介绍了一些数论知识. 有了这些知识,我们就可以看懂RSA算法.这是目前地球上最重要的加密算法. 六.密钥生成的步骤 我们通过一个例子,来理解 ...

  3. retrofit2中ssl的Trust anchor for certification path not found问题

    在retrofit2中使用ssl,刚刚接触,很可能会出现如下错误. java.security.cert.CertPathValidatorException: Trust anchor for ce ...

  4. Log4net使用(一)

    LogHelper.cs using NLog; using NLog.Targets; namespace MyProject.Tool.Log { public class LogHelper { ...

  5. linux基础-附件1 linux系统启动流程

    附件1 linux系统启动流程 最初始阶段当我们打开计算机电源,计算机会自动从主板的BIOS(Basic Input/Output System)读取其中所存储的程序.这一程序通常知道一些直接连接在主 ...

  6. SharedPreference写入-读取

    SharedPreference文件保存格式为xml文件. 一.SharedPreference写入 SharedPreferences sharedPreferences = context.get ...

  7. json写入和读取代码

    #写入new文件 import json dic = {'name':'alex'} i = 8 s = 'hello' l = [11,22] f = open("new_hello&qu ...

  8. navicat cannot create file 文件名、目录名或卷标语法不正确 解决方法

    配置了mycat,用navicat连接8066端口,点击“查询”的时候发现出现报错: 开始以为是mycat的配置有问题,找了好久都没发现错误.根据提示信息进入到相应的目录发现每个连接其实就是一个win ...

  9. [转]Null value was assigned to a property of primitive type setter of"原因及解决方法

    原文地址:http://blog.csdn.net/kevinzhangfei/article/details/6995316 在action请求数据的过程中报出"Null value wa ...

  10. [转]Oracle中使用Rownum分页详细例子

    原文地址:http://www.jb51.net/article/52272.htm 在MySQL中,我们通常都使用limit来完成数据集获取的分页操作,而在Oracle数据库中,并没有类似limit ...