题意:给出三角形的三条中线长度求面积。
#include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int main() { double n,m,p; while(cin>>n>>m>>p) { if((m+n+p)*(m+p-n)*(m+n-p)*(n+p-m)<=0||m<=0||n<=0||p<=0||m+p<=n||n+p<=m||m+n<=p) puts("-1.000"); else printf("%.3lf\n",sqrt((m+n+p)*(m+p-n)*(m+n-p)*(n+p-m))/3.0); } return 0; }
时间: 2024-11-01 12:07:49