zoukankan      html  css  js  c++  java
  • 求三角形的面积


    Description

    给出一个三角形的三个点在平面内的坐标。

    请你来求一求这个三角形的面积是多少。

    Input

    多组输入。

    每行有6个整数。

    前面两个整数是一个点的坐标。

    中间两个整数是另一个点的坐标。

    最后两个整数是最后一个点的坐标。

    Output

    三角形的面积,保留两位小数。

    Sample Input

    0 0 2 0 0 1
    1 2 5 9 6 8
    

    Sample Output

    1.00
    5.50




    #include<iostream>
    #include<stdio.h>
    #include<cmath>
    using namespace std;
    int main()
    {
    double a[3][2];
    while(cin>>a[0][0]>>a[0][1]>>a[1][0]>>a[1][1]>>a[2][0]>>a[2][1])
    {
    double c,d,x,y,l1,l2,B,s;
    c=a[2][0]-a[0][0],d=a[2][1]-a[0][1];
    l1=sqrt(c*c+d*d);
    x=a[2][0]-a[1][0],y=a[2][1]-a[1][1];
    l2=sqrt(x*x+y*y);
    B=acos((c*x+d*y)/(l1*l2));
    s=((double)sin(B)*l1*l2)/2;
    printf("%.2f ",s);
    }
    return 0;
    }

  • 相关阅读:
    各种小知识
    基础技能
    st表
    有理数取余
    FFT加速高精度乘法
    unique
    离散化
    线段树复杂度分析
    楼房重建
    电脑装系统常用方法
  • 原文地址:https://www.cnblogs.com/zhang20115330/p/3151623.html
Copyright © 2011-2022 走看看