Problem Description

输入平面坐标系中2点的坐标,输出它们之间的距离

Input

输入4个浮点数x1 y1 x2 y2,分别是点(x1,y1) (x2,y2)的坐标(多组数据)

Output

输出它们之间的距离,保留2位小数(每组数据一行)

Sample Input

1 0 2 0

Sample Output

1.00

 #include<stdio.h>

 #include<math.h>

 int main()

 {

          float x1,y1,x2,y2;

          double len;

          while(scanf("%f%f%f%f",&x1,&y1,&x2,&y2)!=EOF)

          {

                    len=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

                    printf("%.2lf\n",len);

          }

                    return ;

 }

其他代码:

 #include<stdio.h>
#include<math.h>
int main()
{
double x1,x2,y1,y2;
double distance;
while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF)
{
distance=sqrt(fabs(x1-x2)*fabs(x1-x2)+fabs(y1-y2)*fabs(y1-y2));
printf("%.2lf\n",distance);
}
return ;
}

武汉科技大学ACM :1006: 零起点学算法25——求两点之间的距离的更多相关文章

  1. 武汉科技大学ACM :1010: 零起点学算法12——求2个日期之间的天数

    Problem Description 水题 Input 输入2个日期,日期按照年月日,年月日之间用符号-隔开(题目包含多组数据) Output 求出这2个日期之间的天数(不包括自身),每组测试数据一 ...

  2. 武汉科技大学ACM :1002: 零起点学算法38——求阶乘和

    Problem Description 输入一个正整数n(n<=10),计算 S=1!+2!+3!+...+n! Input 输入一个正整数n(n<=10)(多组数据) Output 输出 ...

  3. Problem E: 零起点学算法25——判断是否直角三角形

    #include<stdio.h> int main() { int a,b,c; while(scanf("%d %d %d",&a,&b,& ...

  4. Problem Z: 零起点学算法22——求正弦和余弦

    #include<stdio.h> #include <math.h> int main() { int n; ); double a,b; while(scanf(" ...

  5. Problem W: 零起点学算法21——求平均值

    #include<stdio.h> int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); pr ...

  6. Problem R: 零起点学算法13——求2个时间之间的分钟数

    #include<stdio.h> int main() { int a1,b1,a2,b2,s; scanf("%d:%d",&a1,&b1); sc ...

  7. Problem Q: 零起点学算法12——求2个日期之间的天数

    #include<stdio.h> int main() { int a1,b1,c1,a2,b2,c2,s; scanf("%d-%d-%d",&a1,&am ...

  8. Problem O: 零起点学算法10——求圆柱体的表面积

    #include<stdio.h> int main() { float r,h,pi; pi=3.1415926; scanf("%f %f",&r,& ...

  9. WUOJ-ACM :1003: 零起点学算法78——牛牛

    武汉科技大学ACM :1003: 零起点学算法78--牛牛Problem Description牛牛是一种纸牌游戏,总共5张牌,规则如下: 如果找不到3张牌的点数之和是10的倍数,则为没牛: 如果其中 ...

随机推荐

  1. winform拖动无边框窗体

    这个无边框拖动船体,代码很少,却总是记不住,于是就在网上搜了这段代码,记录一下,省的再忘 using System; using System.Collections.Generic; using S ...

  2. 主流屏幕对比:IPS/LTPS/CGS/IGZO/AMOLED

    IPS.LTPS.CGS.IGZO.AMOLED都是什么屏幕又有什么区别?目前的手机屏幕技术实在太多,本文旨在介绍各种面板以及屏幕技术,便于大家更好地进行区分. 近年来手机屏幕技术层出不穷,早在几年前 ...

  3. Binary Tree Inorder Traversa

    ​ package cn.edu.xidian.sselab.hashtable; import java.util.ArrayList;import java.util.List;import ja ...

  4. 【HDOJ】4403 A very hard Aoshu problem

    HASH+暴力. /* 4403 */ #include <iostream> #include <cstdio> #include <cstring> #incl ...

  5. COJN 0575 800601滑雪

    800601滑雪 难度级别:B: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是 ...

  6. java容器类总结

    1.java容器分类图 说明:左图为简化图(其中粗线部分是重点的容器),右图为完整容器分类图                          2.容器类接口和抽象容器类 2.1 说明 容器接口是容器 ...

  7. maven,本地仓库和私服nexus的配置,以及eclipse载入maven

    首先可以进入http://maven.apache.org/官网查看如何配置 一.配置环境 1 确定自己的java运行环境配置正确-->在cmd运行 java -version或echo %JA ...

  8. powershell利用winform批量执行tsql语句

    #加载.net的winform模块 [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $app= ...

  9. android获得屏幕高度和宽度

    获取屏幕的宽度与高度有以下几种方法: .WindowManager wm = (WindowManager) getContext()                     .getSystemSe ...

  10. Tomcat: IllegalStateException: No output folder --reference

    Today, I started to create a couple of JSP pages for the server-side part of my MSc thesis project i ...