武汉科技大学ACM :1006: 零起点学算法25——求两点之间的距离
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——求两点之间的距离的更多相关文章
- 武汉科技大学ACM :1010: 零起点学算法12——求2个日期之间的天数
Problem Description 水题 Input 输入2个日期,日期按照年月日,年月日之间用符号-隔开(题目包含多组数据) Output 求出这2个日期之间的天数(不包括自身),每组测试数据一 ...
- 武汉科技大学ACM :1002: 零起点学算法38——求阶乘和
Problem Description 输入一个正整数n(n<=10),计算 S=1!+2!+3!+...+n! Input 输入一个正整数n(n<=10)(多组数据) Output 输出 ...
- Problem E: 零起点学算法25——判断是否直角三角形
#include<stdio.h> int main() { int a,b,c; while(scanf("%d %d %d",&a,&b,& ...
- Problem Z: 零起点学算法22——求正弦和余弦
#include<stdio.h> #include <math.h> int main() { int n; ); double a,b; while(scanf(" ...
- Problem W: 零起点学算法21——求平均值
#include<stdio.h> int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); pr ...
- Problem R: 零起点学算法13——求2个时间之间的分钟数
#include<stdio.h> int main() { int a1,b1,a2,b2,s; scanf("%d:%d",&a1,&b1); sc ...
- Problem Q: 零起点学算法12——求2个日期之间的天数
#include<stdio.h> int main() { int a1,b1,c1,a2,b2,c2,s; scanf("%d-%d-%d",&a1,&am ...
- Problem O: 零起点学算法10——求圆柱体的表面积
#include<stdio.h> int main() { float r,h,pi; pi=3.1415926; scanf("%f %f",&r,& ...
- WUOJ-ACM :1003: 零起点学算法78——牛牛
武汉科技大学ACM :1003: 零起点学算法78--牛牛Problem Description牛牛是一种纸牌游戏,总共5张牌,规则如下: 如果找不到3张牌的点数之和是10的倍数,则为没牛: 如果其中 ...
随机推荐
- codevs 1217 借教室
传送门 1217 借教室 2012年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Descripti ...
- optimize the performance
http://en.wikipedia.org/wiki/Web_Performance_Optimization http://www.stevesouders.com/blog/2011/08/2 ...
- Nodejs in Visual Studio Code 02.学习Nodejs
1.开始 源码下载:https://github.com/sayar/NodeMVA 在线视频:https://mva.microsoft.com/en-US/training-courses/usi ...
- shell变量自增的几种方式
#!/bin/sh a= a=$(($a+)) a=$[$a+] a=`` let a++ let a+= ((a++)) echo $a 输出 : 转载自:http://blog.csdn.net/ ...
- 一个简单的TestNG例子
关于TestNG好的资源: 官网文档:http://testng.org/doc/documentation-main.html 一 下载并安装:1. JDK 1.7 $ java -version ...
- mvc知识应用
mvc 添加 Roche.Models.Logincodes per = new Roche.Models.Logincodes(); per.Qrcode = data.Qrcode; per.Co ...
- SKPhysicsJointSpring类
继承自 NSObject 符合 NSCoding(SKPhysicsJoint)NSObject(NSObject) 框架 /System/Library/Frameworks/SpriteKit. ...
- VB.NET版机房收费系统---七仙女之系统登录
VB.NET第一版机房收费系统,告一段落,验收的时候.问题也是大大的存在,没实用上设计模式,什么触发器.存储过程,都没实用上.看看其她小伙伴的,七层实现登录?那是什么东东,相比較我的三层而言,多了两倍 ...
- Android入门之ActionBar实现Tab导航
效果图: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=&qu ...
- Cross-origin resource sharing--reference
Cross-origin resource sharing (CORS) is a mechanism that allows many resources (e.g., fonts, JavaScr ...