手打向量(不是 )
#include <iostream>
#include <cmath>
#define db double
using namespace std;
#define ri register int
inline void syncwithme(){
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
}
struct victor{
db x,y;
victor() { }
victor(db x,db y) : x(x),y(y){}
inline victor operator +(const victor &a){ return victor(x+a.x,y+a.y); } //加
inline victor operator -(const victor &a){ return victor(x-a.x,y-a.y); } //减
inline db operator *(const victor &a){ return x*a.x+y*a.y; } //点积
inline db operator ^(const victor &a){ return x*a.y-y*a.x; } //叉积的值
inline void operator +=(const victor &a){ x+=a.x,y+=a.y; }
inline void operator -=(const victor &a){ x-=a.x,y-=a.y; }
inline bool operator ==(const victor &a){ return x==a.x&&y==a.y; } //判断两个向量相等
inline bool iszero(){ return (!x)&&(!y); } //判断是否是零向量
};
int main()
{
syncwithme();
return 0;
}#include <iostream>
#include <cmath>
#define db double
using namespace std;
#define ri register int
inline void syncwithme(){
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
}
struct victor{ //万 恶 之 源
db x,y;
victor() { }
victor(db x,db y) : x(x),y(y){}
inline victor operator +(const victor &a){ return victor(x+a.x,y+a.y); } //加
inline victor operator -(const victor &a){ return victor(x-a.x,y-a.y); } //减
inline db operator *(const victor &a){ return x*a.x+y*a.y; } //点积
inline db operator ^(const victor &a){ return x*a.y-y*a.x; } //叉积的值
inline void operator +=(const victor &a){ x+=a.x,y+=a.y; }
inline void operator -=(const victor &a){ x-=a.x,y-=a.y; }
inline bool operator ==(const victor &a){ return x==a.x&&y==a.y; } //判断两个向量相等
inline bool iszero(){ return (!x)&&(!y); } //判断是否是零向量
};
victor node[4],pt,temp[4];
int main()
{
syncwithme();
register char rubbish;
cin>>rubbish>>node[1].x>>rubbish>>node[1].y>>rubbish;
cin>>rubbish>>node[2].x>>rubbish>>node[2].y>>rubbish;
cin>>rubbish>>node[3].x>>rubbish>>node[3].y>>rubbish;
cin>>rubbish>>pt.x>>rubbish>>pt.y>>rubbish;
ri ans; db t1,t2,t3;
if(pt==node[1]||pt==node[2]||pt==node[3]) ans=4; //在三角形顶点上
else{
temp[1]=node[1]-pt,
temp[2]=node[2]-pt,
temp[3]=node[3]-pt; //求出向量PA,PB,PC
t1=temp[1]^temp[2],
t2=temp[2]^temp[3],
t3=temp[3]^temp[1]; //求出它们逆时针顺次的叉积
if(!t1&&!t2&&!t3) ans=2; //三个叉积都是0说明三角形三个顶点重合
else if(t1&&t2&&t3) ans=(t1*t2>0&&t2*t3>0&&t3*t1>0)?1:2; //如果三个叉积都不为0说明要么在内部要么在外部
else{ //某个叉积是0,说明在三角形一条边所在的直线上(注意不一定就在边上)
if(!t1) ans=(t2*t3>0)?3:2;
if(!t2) ans=(t1*t3>0)?3:2;
if(!t3) ans=(t1*t2>0)?3:2; //就判断剩下两个是否同号,同号就在边上,否则在外部
}
} cout<<ans;
return 0;
}