POJ2208 Pyramids 四面体体积

POJ2208给定四面体六条棱(有序)的长度 求体积

显然用高中立体几何的方法就可以解决。

给出代码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
using namespace std;
double Volume(double l,double n,double a,double m,double b,double c)
{
 double x,y;
 x=4*a*a*b*b*c*c-a*a*(b*b+c*c-m*m)*(b*b+c*c-m*m)-b*b*(c*c+a*a-n*n)*(c*c+a*a-n*n);
 y=c*c*(a*a+b*b-l*l)*(a*a+b*b-l*l)-(a*a+b*b-l*l)*(b*b+c*c-m*m)*(c*c+a*a-n*n);
 return(sqrt(x-y)/12.);
}
int main()
{freopen("t.txt","r",stdin);
 double l1,l2,l3,l4,l5,l6;
 cin>>l1>>l2>>l3>>l4>>l5>>l6;
 printf("%.4lf
",Volume(l1,l2,l3,l4,l5,l6)+0.0000005);
 return 0;
 } 

  

原文地址:https://www.cnblogs.com/heisenberg-/p/6771597.html