Pagini recente » Cod sursa (job #2463289) | Cod sursa (job #2872372) | Cod sursa (job #1953907) | Cod sursa (job #188211) | Cod sursa (job #1501230)
#include <iostream>
using namespace std;
float x1,x2,x3,x4,y1,y2,y3,y4;
void Citire()
{
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
}
int ecuatii(int x1,int y1,int x2,int y2)
{
if(x1 == x4 && y1 == y4 || x2 == x4 && y2 == y4 || x3 == x4 && y3 == y4)
{
cout << "Se afla pe unul din varfuri";
return 2;
}
else
{
int a = y1 - y2;
int b = x2 - x1;
int c = (x1*y2)-(y1*x2);
int h = a*x4 + b*y4 + c;
if(h == 0)
{
cout << "Coliniar";
return 0;
}
else
if(h < 0)
return -1;
else
return 1;
}
}
int main()
{
Citire();
if(ecuatii(x1,y1,x2,y2) != 0 && ecuatii(x1,y1,x2,y2) != 2)
int pn=0,sn=0;
if(ecuatii(x1,y1,x2,y2) == 1)
pn++;
else if(ecuatii(x1,y1,x2,y2) == -1)
sn++;
if(ecuatii(x2,y2,x3,y3))
pn++;
else if(ecuatii(x2,y2,x3,y3) == -1)
sn++;
if(ecuatii(x1,y1,x3,y3))
pn++;
else if(ecuatii(x1,y1,x3,y3) == -1)
sn++;
if(sn + pn > 2)
if(sn == 1 && pn == -2)
cout << "E in interiorul triunghiului\n";
else cout << "E in afara triunghiului\n";
return 0;
}