Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct punkt
- {
- int x,y;
- };
- punkt CzytP(int &z)
- {
- punkt p;
- cin>>p.x; z|=p.x;
- cin>>p.y; z|=p.y;
- return p;
- }
- int CzytTr(punkt T[])
- {
- int z=0;
- for(int i=0;i<3;i++)
- {
- T[i]=CzytP(z);
- }
- return z;
- }
- int Wejscie(punkt T[], punkt &A)
- {
- int wy=0;
- wy|=CzytTr(T);
- A=CzytP(wy);
- return wy;
- }
- punkt Wekt(punkt A, punkt B)
- {
- punkt p;
- p.x=B.x-A.x;
- p.y=B.y-A.y;
- return p;
- }
- int Wyzn(punkt w1,punkt w2)
- {
- int w=w1.x*w2.y-w1.y*w2.x;
- if(w==0) return 1;
- else if(w>0) return 2;
- else return 4;
- }
- char Odp(punkt T[], punkt A)
- {
- int odp=0;
- for(int i=0;i<3;i++)
- {
- odp|=Wyzn(Wekt(T[i],T[(i+1)%3]), Wekt(T[i],A));
- }
- if(odp<6)
- {
- if(odp%2==0) return 'I';
- else return 'E';
- }
- return 'O';
- }
- int main()
- {
- punkt A,trojk[3];
- while(Wejscie(trojk,A))
- {
- cout<<Odp(trojk,A)<<endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement