1305 - Area of a Parallelogram
题意:给定平行四边形的3个顶点的坐标,求第四个点的坐标和平行四边形的面积。
思路:几何基础题,不过用向量比较简单。
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1305
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio>
2 #include <cstring>
3 #include <cmath>
4 #include <string>
5 #include <algorithm>
6 #include <iostream>
7 using namespace std;
8
9 typedef struct In{
10 int x;
11 int y;
12 }In;
13 In a,b,c,d;
14
15 int area(In a,In b,In d){
16 return (b.x-a.x)*(d.y-a.y)-(b.y-a.y)*(d.x-a.x);
17 }
18
19 int main(){
20
21 // freopen("data.in","r",stdin);
22 // freopen("data.out","w",stdout);
23
24 int t,i;
25 scanf("%d",&t);
26 for(i=1;i<=t;i++){
27 scanf("%d%d%d%d%d%d",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
28 d.x=a.x-b.x+c.x; // 向量
29 d.y=a.y-b.y+c.y;
30 int ans=area(a,b,d);
31 printf("Case %d: %d %d %d\n",i,d.x,d.y,abs(ans));
32 }
33 return 0;
34 }