zoukankan      html  css  js  c++  java
  • 一月24日新生冬季练习赛解题报告D.三角形面积

    水的离谱:

    啊啊啊啊啊啊

    已知三边求面积可以:

    #include<iostream>

    #include<string.h>

    #include<stdio.h>

    #include<queue>

    #include<stack>

    #include<map>

    #include<vector>

    #include<cmath>

    #include<iomanip>

    using namespace std;

     

    struct point

    {

        double x;

        double y;

    }poin[101];

     

    int main()

    {

        int t;

        cin>>t;

        while(t--)

        {

            cin>>poin[0].x>>poin[0].y>>poin[1].x>>poin[1].y>>poin[2].x>>poin[2].y;

            double a=sqrt(pow((poin[0].x-poin[1].x)*1.0,2.0)+(pow((poin[0].y-poin[1].y)*1.0,2.0)));

            double b=sqrt(pow((poin[0].x-poin[2].x)*1.0,2.0)+(pow((poin[0].y-poin[2].y)*1.0,2.0)));

            double c=sqrt(pow((poin[2].x-poin[1].x)*1.0,2.0)+(pow((poin[2].y-poin[1].y)*1.0,2.0)));

        if(a+b>c&&a+c>b&&b+c>a)

            {

                double d=0.5*(a+b+c);

                double s=sqrt(d*(d-a)*(d-b)*(d-c));

                cout<<setprecision(2)<<std::fixed<<s<<endl;

            }

            else

                cout<<"fail"<<endl;

          }

          return 0;

    }

     

    茶几也可以:

    #include<iostream>

    #include<string.h>

    #include<stdio.h>

    #include<queue>

    #include<stack>

    #include<map>

    #include<vector>

    #include<cmath>

    #include<iomanip>

    using namespace std;

     

    #define minn 1e-8

     

    struct point

    {

        double x;

        double y;

    }poin[101];

     

    double cross(point p1,point p0,point p2)

    {

        return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p1.y);

    }

     

    int main()

    {

        int t;

        cin>>t;

        while(t--)

        {

            cin>>poin[0].x>>poin[0].y>>poin[1].x>>poin[1].y>>poin[2].x>>poin[2].y;

            double ans=cross(poin[1],poin[0],poin[2]);

            if(ans<=minn&&ans+minn>=0)

                 cout<<"no"<<endl;

            else

               cout<<ans/2<<endl;

        }

        return 0;

    }

     

  • 相关阅读:
    tomcat监控
    rsync排除文件同步
    [转载]centos7 快速安装 mariadb(mysql)
    linux下的头文件和库文件搜索路径 (转)
    用apt-get install一个软件的时候出现错误: 无法解析或打开软件包的列表或是状态文件
    模拟一个简单的基于tcp的远程关机程序(转)
    TCP连接的建立以及利用tcpdump分析连接建立的过程(转)
    UNIX网络编程(转载)
    开源代码网站(转)
    学了5天Arm,今天谈谈初学感受 (转)
  • 原文地址:https://www.cnblogs.com/zhanzhao/p/3532956.html
Copyright © 2011-2022 走看看