三角形判断求c++解法

img

#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
    int x1,y1,x2,y2,x3,y3;
    double l1,l2,l3;
    double p,s;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    
    //计算边长
    l1 = sqrt((double)(x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    l2 = sqrt((double)(x1-x3)*(x1-x3) + (y1-y3)*(y1-y3));
    l3 = sqrt((double)(x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));

    if(l1 + l2 >l3 && l1+l3>l2 && l2+l3 > l1)
    {
        p = (l1+l2+l3)/2.0;
        s = sqrt(p*(p-l1)*(p-l2)*(p-l3));
        cout << fixed<< setprecision(2)<< "L = "  << p << ",A = " << s;
    }else
        cout << "Impossible";
    return 0;
}