... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Tuesday, December 31, 2013

LOJ-1305 :: Area of a Parallelogram

#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std ;
int main ()
{
     double h,k , x1,x2,x3,x4,y1,y2,y3,y4,s,n,a,c ,b ;
     int t,i ,it=1;
    cin>>t ;

    while (it<=t )
    {
        cin>>x1>>y1>>x2>>y2>>x3>>y3 ;

        h=(x1+x3)/2.00 ;
        k=(y1+y3)/2.00 ;

        x4=2.00*h-x2 ;
        y4=2.00*k-y2 ;

        a= 1.0*sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;
        b= 1.0*sqrt((x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) ;
        c=1.0* sqrt((x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) ;

        s= (a+b+c)/2.00 ;
        n=2.0*sqrt(s*(s-a)*(s-b)*(s-c) ) ;
        if (n<0) n=(-1.0)*n ;

        printf ("Case %d: %.0lf %.0lf %.0lf\n",it,x4,y4,n) ;
        it++ ;
    }

    return 0 ;
}