hdu_2001_计算两点间的距离_水之

来源:互联网 发布:北京金和软件 编辑:程序博客网 时间:2024/04/30 03:45

用setprecision设置小数位数会自动省略0例如1.00他会输出1

没试过会不会ac....

http://acm.hdu.edu.cn/showproblem.php?pid=2001

计算两点间的距离

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 40522    Accepted Submission(s): 15304


Problem Description
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
 

Input
输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。
 

Output
对于每组输入数据,输出一行,结果保留两位小数。
 

Sample Input
0 0 0 10 1 1 0
 

Sample Output
1.001.41
 
      1. #include<iostream>
      2. #include<stdio.h>
      3. #include<math.h>
      4. using namespace std;
      5. int main()
      6. {
      7. double x1,y1,x2,y2,a,b;
      8. while(cin>>x1>>y1>>x2>>y2)
      9. {
      10. a=x1-x2;b=y1-y2;
      11. printf("%.2f\n",sqrt(a*a+b*b));
      12. }
      13. return 0;
      14. }

原创粉丝点击