Lightoj 1305 Area of a Parallelogram Solution
Problem Link: https://lightoj.com/problem/area-of-a-parallelogram
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long t, i,area,ax,ay,bx,by,cx,cy,dx,dy;;
cin>>t;
for (i=1; i<=t; i++)
{
cin>>ax>>ay>>bx>>by>>cx>>cy;
dx= ax+cx-bx;
dy = ay+cy-by;
area=0.5*(((ax*by)+(bx*cy)+(cx*dy)+(dx*ay))-((ay*bx)+(by*cx)+(cy*dx)+(dy*ax)));
if (area< 0)
area*=-1;
printf("Case %d: %d %d %d\n",i,dx,dy,area);
}
return 0;
}
No comments