水的离谱:
啊啊啊啊啊啊
已知三边求面积可以:
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
struct point
{
double x;
double y;
}poin[101];
int main()
{
int t;
cin>>t;
while(t--)
{
cin>>poin[0].x>>poin[0].y>>poin[1].x>>poin[1].y>>poin[2].x>>poin[2].y;
double a=sqrt(pow((poin[0].x-poin[1].x)*1.0,2.0)+(pow((poin[0].y-poin[1].y)*1.0,2.0)));
double b=sqrt(pow((poin[0].x-poin[2].x)*1.0,2.0)+(pow((poin[0].y-poin[2].y)*1.0,2.0)));
double c=sqrt(pow((poin[2].x-poin[1].x)*1.0,2.0)+(pow((poin[2].y-poin[1].y)*1.0,2.0)));
if(a+b>c&&a+c>b&&b+c>a)
{
double d=0.5*(a+b+c);
double s=sqrt(d*(d-a)*(d-b)*(d-c));
cout<<setprecision(2)<<std::fixed<<s<<endl;
}
else
cout<<"fail"<<endl;
}
return 0;
}
茶几也可以:
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
#define minn 1e-8
struct point
{
double x;
double y;
}poin[101];
double cross(point p1,point p0,point p2)
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p1.y);
}
int main()
{
int t;
cin>>t;
while(t--)
{
cin>>poin[0].x>>poin[0].y>>poin[1].x>>poin[1].y>>poin[2].x>>poin[2].y;
double ans=cross(poin[1],poin[0],poin[2]);
if(ans<=minn&&ans+minn>=0)
cout<<"no"<<endl;
else
cout<<ans/2<<endl;
}
return 0;
}