已知三角形三个顶点求三角形内心

#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
double x[3],y[3];
int main()
{
    while(~scanf("%lf%lf",&x[0],&y[0]))
    {
        scanf("%lf%lf",&x[1],&y[1]);
        scanf("%lf%lf",&x[2],&y[2]);
        double c=sqrt((x[0]-x[1])*(x[0]-x[1])+ (y[0]-y[1])*(y[0]-y[1]));
        double a=sqrt((x[1]-x[2])*(x[1]-x[2])+ (y[1]-y[2])*(y[1]-y[2]));
        double b=sqrt((x[2]-x[0])*(x[2]-x[0])+ (y[2]-y[0])*(y[2]-y[0]));
        printf("%.2lf %.2lf ",(a*x[0]+b*x[1]+c*x[2])/(a+b+c), (a*y[0]+b*y[1]+c*y[2])/(a+b+c));
    }
    return 0;
}

原文地址:https://www.cnblogs.com/lxm940130740/p/3362063.html