WOJ1286-Area Ratio

探讨了如何计算三角形内切圆与外接圆面积之比的问题,并提供了一个具体的编程实现方案,通过输入三个顶点坐标来计算该比率。

Given a triangle, what is the ratio of the area of its inscribed circle to that of its circum circle?

输入格式

9 integers x1 y1 z1 x2 y2 z2 x3 y3 z3 on one line (-1000 <= x,y,z <= 1000), the three coordinates of the triangle(they will not appear in the same line).
You should process the input until "EOF". Your code should be something like:
while(scanf("%f%f.....",&a,&b,....)!=EOF)/ C/C++ /
{Your code here.};
OR
while(cin >> a >>b ) / C++ /
{Your code here.};

输出格式

One ratio per line, exact to three digits to the right of the decimal point.

样例输入

0 0 0 0 0 1 0 1 0


#include<stdio.h>
#include<math.h>
int main(){
    int d[9];
    double a,b,c,p,s,w,n;
    while(scanf("%d %d %d %d %d %d %d %d %d",&d[0],&d[1],&d[2], &d[3],&d[4],&d[5], &d[6],&d[7],&d[8])!=EOF){
        a=sqrt((double)(pow((double)(d[0]-d[3]),2)+pow((double)(d[1]-d[4]),2)+pow((double)(d[2]-d[5]),2)));
        b=sqrt((double)(pow((double)(d[0]-d[6]),2)+pow((double)(d[1]-d[7]),2)+pow((double)(d[2]-d[8]),2)));
        c=sqrt((double)(pow((double)(d[6]-d[3]),2)+pow((double)(d[7]-d[4]),2)+pow((double)(d[8]-d[5]),2)));
        p=(a+b+c)/2;
        s=sqrt(p*(p-a)*(p-b)*(p-c));
        w=pow(a*b*c/(4*s),2);
        n=pow(2*s/(a+b+c),2);
        printf("%.3f\n",n/w);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值