• lightoj 1305


    Area of a Parallelogram
     
    Time Limit: 1 second(s) Memory Limit: 32 MB

    A parallelogram is a quadrilateral with two pairs of parallel sides. See the picture below:

    Fig: a parallelogram

    Now you are given the co ordinates of A, B and C, you have to find the coordinates of D and the area of the parallelogram. The orientation of ABCD should be same as in the picture.

    Input

    Input starts with an integer T (≤ 1000), denoting the number of test cases.

    Each case starts with a line containing six integers Ax, Ay, Bx, By, Cx, Cy where (Ax, Ay) denotes the coordinate of A(Bx, By) denotes the coordinate of B and (Cx, Cy) denotes the coordinate of C. Value of any coordinate lies in the range [-1000, 1000]. And you can assume that A, B and C will not be collinear.

    Output

    For each case, print the case number and three integers where the first two should be the coordinate of D and the third one should be the area of the parallelogram.

    Sample Input

    Output for Sample Input

    3

    0 0 10 0 10 10

    0 0 10 0 10 -20

    -12 -10 21 21 1 40

    Case 1: 0 10 100

    Case 2: 0 -20 200

    Case 3: -32 9 1247

    【题解】题中没有限定第四个点的位置吗?????不是这样的,细心地人不难发现1+3-2就是第四个点,然后可以根据三角形的面积公式进行计算。

    公式一:S = abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)) / 2

    公式二:S = ah÷2    三角形的面积=底×高÷2;

    公式三:S = ab×sin×1/2   三角形任意两边之积×这两边的夹角的正弦值÷2;   

    公式四:2、海伦公式:S = √[p(p-a)(p-b)(p-c) ]其中p=1/2(a+b+c);

    公式五:s=1/2的周长*内切圆半径;

    在这一题中建议采用第一种方式,相对而言来说最简单!!!!!!

    AC代码:

     1 #include<cstdio>
     2 #include<cmath>
     3 #include<algorithm>
     4 using namespace std;
     5 struct node{
     6     double x, y;
     7 }s[5];
     8 int main()
     9 {
    10     int t, Case = 1;
    11     scanf("%d", &t);
    12     while(t--)
    13     {
    14         for(int i = 1; i <= 3; i++)
    15         scanf("%lf %lf", &s[i].x, &s[i].y);
    16         s[4].x = s[1].x + s[3].x - s[2].x;
    17         s[4].y = s[1].y + s[3].y - s[2].y;
    18         double sum = abs((s[2].x-s[1].x)*(s[3].y-s[1].y) - (s[3].x-s[1].x)*(s[2].y-s[1].y)); 
    19         printf("Case %d: %.lf %.lf %.lf
    ", Case++, s[4].x, s[4].y, sum);
    20     }
    21     return 0;
    22 }
  • 相关阅读:
    纹理贴图的模式设置
    vs debug或者release文件夹下的 .exe文件
    subpixel的概念
    点乘
    设置开机时自动开启和关闭的软件
    CF553E Kyoya and Train
    CF960G Bandit Blues
    玩游戏
    「SWTR03」Counting Trees
    CF623E Transforming Sequence
  • 原文地址:https://www.cnblogs.com/123tang/p/5877978.html
Copyright © 2020-2023  润新知