zoukankan      html  css  js  c++  java
  • 包含

    #include<iostream>
    #include<cmath>
    using namespace std;
    class Point
    {
        double x,y;
    public:
        Point(double x = 0,double y = 0)
        {
            this -> x = x;
            this -> y =y;
        }
        double getx()
        {
            return x;
        }
        double gety()
        {
            return y;
        }
    };
    class Line
    {
        Point p1,p2;
    public:
        Line(const Point &a,const Point &b): p1(a),p2(b) {}
        double getDistance()
        {
            double detax,detay;
            detax = p1.getx() - p2.getx();
            detay = p1.gety() - p2.gety();
            return sqrt(detax * detax + detay * detay);
        }
    };
    class Triangle
    {
        Line z1,z2,z3;
    public:
        Triangle(const Line &a,const Line &b,const Line &c):z1(a),z2(b),z3(c) {}
        double Area()
        {
            double p,q;
            p=((z1.getDistance()+z2.getDistance()+z3.getDistance())/2);
            q=sqrt(p*((p-z1.getDistance())*(p-z2.getDistance())*(p-z3.getDistance())));
            return q;
        }
    };
    int main()
    {
        float p1,p2,p3,p4,p5,p6;
        cin>>p1>>p2>>p3>>p4>>p5>>p6;
        Point a(p1,p2),b(p3,p4),c(p5,p6);
        Line d(a,b),e(b,c),f(c,a);
        Triangle z(d,e,f);
        double distance,area;
        distance=d.getDistance()+e.getDistance()+f.getDistance();
        area=z.Area();
        cout<<distance<<' '<<area<<endl;
        return 0;
    }
  • 相关阅读:
    SQL 语言入门
    [转载]Sql Server 中的Login,Schema,User,Role之间的关系
    稀疏矩阵运算
    特征缩放的几种方法
    dp解出栈序列数
    神经网络解决多分类问题例:数字识别
    多分类例题
    fminunc 函数的用法
    二分类
    特征归一化、特征映射、正则化
  • 原文地址:https://www.cnblogs.com/handsometaoa/p/11008276.html
Copyright © 2011-2022 走看看