Nazariy qism. If va if else


Download 157.21 Kb.
bet2/3
Sana21.11.2020
Hajmi157.21 Kb.
#149706
1   2   3
Bog'liq
3- labaratoriya


2-Masalaning qo’yilishi:

17.

Uchburchak uchlarining koordinatalari , va berilgan. Berilgan nuqta uchburchak ichida yotish yoki yotmasligi aniqlansin.

#include

#include

using namespace std;

float s3(float x1, float y1, float x2, float y2, float x3, float y3){

return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;

}

int main()



{

float x1,x2,x3,x,y1,y2,y3,y;

cout<<"x="; cin>>x;

cout<<"x1="; cin>>x1;

cout<<"x2="; cin>>x2;

cout<<"x3="; cin>>x3;

cout<<"y="; cin>>y;

cout<<"y1="; cin>>y1;

cout<<"y2="; cin>>y2;

cout<<"y3="; cin>>y3;

bool dotIsIn = s3(x1,y1,x2,y2,x3,y3) == s3(x,y,x1,y1,x2,y2) + s3(x,y,x1,y1,x3,y3) + s3(x,y,x2,y2,x3,y3);

cout << (dotIsIn ? "Ichkarida" : "Tashqarida");

}


Download 157.21 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling