Chinaunix首页 | 论坛 | 博客
  • 博客访问: 105036
  • 博文数量: 20
  • 博客积分: 506
  • 博客等级: 下士
  • 技术积分: 216
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-08 21:10
文章分类

全部博文(20)

文章存档

2011年(20)

我的朋友

分类: C/C++

2011-03-25 22:24:12

Time Limit: 1sec    Memory Limit:32MB
 
Description
请用类描述顶点信息,输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

 

Input

输入数据第一行一个整数 n,代表测试数据组数,接下来 n 行,每行由 4 个实数组成,分别表示 x1,y1,x2,y2,数据之间用空格隔开。

 

Output

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

 

Sample Input
2
0 0 0 1
0 1 1 0
 
Sample Output
1.00
1.41
 
 
 
 
  1. // source code of submission 684632, Zhongshan University Online Judge System

  2. #include<stdio.h>
  3. #include<math.h>
  4. struct nood
  5. {
  6.   double a;
  7.   double b;
  8.   double c;
  9.   double d;
  10. };

  11. int main()
  12. {
  13.  int t,x;
  14.  int i;
  15.  double j;
  16.  scanf("%d",&t);
  17.  struct nood m[t];
  18.  x=t;
  19.  i=0;
  20.  while(t)
  21.  {
  22.   scanf("%lf%lf%lf%lf",&m[i].a,&m[i].b,&m[i].c,&m[i].d);
  23.   i++;
  24.   t--;
  25.  }
  26.  i=0;
  27.   while(x)
  28.  {
  29.   j=sqrt(pow(m[i].d-m[i].b,2)+pow(m[i].c-m[i].a,2));
  30.   printf("%.2lf\n",j);
  31.   x--;
  32.   i++;
  33.  }
  34.  return 0;
  35. }
阅读(1231) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~