Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Date su 4 tacke. Izracunati P cetvorougla (voditi racuna da li su tacke kolinearne ili ne).
- Pomoc: Koristiti funkciju "duzina duzi".
- A(x1,y1), B(x2,y2), C(x3,y3), D(x4,y4).
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- using namespace std;
- float duzinaStrane (float a, float b, float c, float d)
- {
- return sqrt(pow(a-c,2) + pow(b-d,2));
- }
- float povrsina (float a, float b, float c)
- {
- float s = (a+b+c)*0.5;
- float d = (s*(s-a)*(s-b)*(s-c));
- return d;
- }
- int main()
- {
- float x1,y1,x2,y2,x3,y3,x4,y4, min, ab, bc, cd, ad, ac, obim, pov;
- cout<<"Unesite koordinate tacke A: "<<endl;
- cin>>x1>>y1;
- cout<<"Unesite koordinate tacke B: "<<endl;
- cin>>x2>>y2;
- cout<<"Unesite koordinate tacke C: "<<endl;
- cin>>x3>>y3;
- cout<<"Unesite koordinate tacke D: "<<endl;
- cin>>x4>>y4;
- ab = duzinaStrane(x1,y1,x2,y2);
- bc = duzinaStrane(x2,y2,x3,y3);
- cd = duzinaStrane(x3,y3,x4,y4);
- ad = duzinaStrane(x1,y1,x4,y4);
- ac = sqrt(pow (x1-x3,2) + pow ((y1-y3),2));
- pov = povrsina(ad,ac,cd) + povrsina(ab, bc, ac);
- obim = ab+bc+cd+ad;
- cout<<"Obim je: " << obim<<endl;
- cout<<"Povrsina je: "<< povrsina<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement