#include #include using namespace std; int det(int a[3][3], int b[3][3], int c[3][3]) { return ( (a[0][0] * a[1][1] * a[2][2]) + (a[0][1] * a[1][2] * a[2][0]) + (a[0][2] * a[1][0] * a[2][1]) ) - ( (a[0][1] * a[1][0] * a[2][2]) + (a[0][0] * a[1][2] * a[2][1]) + (a[0][2] * a[1][1] * a[2][0]) ); } int det(int b[3][3]) { return ( (b[0][0] * b[1][1] * b[2][2]) + (b[0][1] * b[1][2] * b[2][0]) + (b[0][2] * b[1][0] * b[2][1]) ) - ( (b[0][1] * b[1][0] * b[2][2]) + (b[0][0] * b[1][2] * b[2][1]) + (b[0][2] * b[1][1] * b[2][0]) ); } int main() { ifstream plik; ofstream plikZapis; plik.open("dane.txt"); plikZapis.open("wynik.txt"); int x1,x2,x3,x4,y1,y2,y3,y4; while( !plik.eof() ) { plik >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4; } int tab[3][3] = {x1,y1,1, x2,y2,1, x4,y4,1 }; int tab2[3][3] = {x2,y2,1, x3,y3,1, x4,y4,1 }; int tab3[3][3] = {x3,y3,1, x1,y1,1, x4,y4,1 }; cout << det(tab) << endl; cout << det(tab2) << endl; cout << det(tab3) << endl; if(det(tab) < 0 && det(tab2) < 0 && det(tab3) < 0 ) cout << "Punkt D znajduje sie w trojkacie."; else if(det(tab) > 0 && det(tab2) > 0 && det(tab3) > 0 ) cout << "Punkt D znajduje sie w trojkacie."; else if (det(tab) == 0 || det(tab2) == 0 || det(tab3) == 0 ) cout << "Punkt D znajduje sie sie na jednym z odcinkow trojkata."; else cout << "Punkt nie lezy w trojkacie";