天天看點

joj2000

joj2000
joj2000
joj2000
Logout
My Account
My Groups

joj2000
2000: Simple Problem IV

Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
joj2000
1s 10240K 1729 685 Standard

Give three vertexs of a triangle, calculate the perimeter of the triangle.

Input

There are several test cases in the input file. The first line of the input file is an integer T, indicates the number of test cases.Then following T lines, each line contain six floating-point numbers:

Ax Ay Bx By Cx Cy

indicates the coordinates of the three vertexs.

Output

For each test case print the perimeter in a single line. The result should be rounded to the nearest thousandth.

Sample Input

2
0.0 0.0 0.0 1.0 1.0 0.0
1.0 1.0 2.0 0.0 3.0 1.0
      

Sample Output

3.414
4.828
      

This problem is used for contest: 3 

Submit / Problem List / Status / Discuss

Problem Set with Online Judge System Version 3.12

Jilin University

Developed by skywind, SIYEE

#include<cstdio>

#include<math.h>

double out(double ax,double ay,double bx,double by,double cx,double cy)

{

    double ab=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));

    double ac=sqrt((ax-cx)*(ax-cx)+(ay-cy)*(ay-cy));

    double bc=sqrt((bx-cx)*(bx-cx)+(by-cy)*(by-cy));

    return ab+bc+ac;

}

int main()

{

    int n;

    scanf("%d",&n);

    double ax,ay,bx,by,cx,cy;

    double sum;

    for(int i=0;i<n;i++)

    {

        scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&cx,&cy);

        sum=out(ax,ay,bx,by,cx,cy);

        printf("%.3lf\n",sum);

    }

    return 0;

}

上一篇: joj2511
下一篇: 1177

繼續閱讀