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. 学习Python的三种境界

    前言 王国维在<人间词话>中将读书分为了三种境界:"古今之成大事业.大学问者,必经过三种之境界:'昨夜西风凋碧树,独上高楼,望尽天涯路'.此第一境也.'衣带渐宽终不悔,为伊消得人 ...

  2. X240s安装Win7 以及如何启用ExpressCache

    新买了一台X240S笔记本,尝试了带的Win8正版一个月后,实在无法适应Win8,干脆退回Win7完事,以下为安装过程, 第一步:制作启动U盘 首先,下载一个iso格式的Win7安装镜像文件,利用微软 ...

  3. redis连接数

    1.应用程序会发起多少个请求连接?1)对于php程序,以短连接为主.redis的连接数等于:所有web server接口并发请求数/redis分片的个数.2)对于java应用程序,一般使用JedisP ...

  4. iOS的TCP/IP协议族剖析&&Socket

    原创文章,版权声明:自由转载-非商用-非衍生-保持署名 | Creative Commons BY-NC-ND 3.0 简介 该篇文章主要回顾--TCP/IP协议族中的TCP/UDP.HTTP:还有S ...

  5. java多态实现原理

    众所周知,多态是面向对象编程语言的重要特性,它允许基类的指针或引用指向派生类的对象,而在具体访问时实现方法的动态绑定.C++ 和 Java 作为当前最为流行的两种面向对象编程语言,其内部对于多态的支持 ...

  6. iOS不得姐项目--封装状态栏指示器(UIWindow实现)

    一.头文件 #import <UIKit/UIKit.h> @interface ChaosStatusBarHUD : NSObject /** 显示成功信息 */ + (void)sh ...

  7. Django- 1- 数据库设置

    更改配置文件中的 字段更改为 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', //按照自己的数据库配置配置,现在所配置 ...

  8. 【CodeVS 2822】爱在心中

    “每个人都拥有一个梦,即使彼此不相同,能够与你分享,无论失败成功都会感动.爱因为在心中,平凡而不平庸,世界就像迷宫,却又让我们此刻相逢Our Home.” 在爱的国度里有N个人,在他们的心中都有着一个 ...

  9. Mybatis 自动生成代码

    准备条件: 将下面的文件放入同一目录下 操作步骤: 1/ 在 generatorConfig.xml 中配置相关的参数,与需要被自动生成的表 也可以 执行项目中的MybatisConfigAutoGe ...

  10. bzoj4409&&bzoj4410&&bzoj4411[Usaco2016 Feb Platinum]题解

    辣鸡wyz最近状态奇差,于是想用usaco题找找手感,万万没想到被虐了一脸TAT 先贴代码,有空再填坑 4409[Usaco2016 Feb]Circular barn #include <io ...