Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // zadanie_3.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- float ploshad(int x1, int y1, int x2, int y2, int x3, int y3)
- {
- //cout<<"x: "<<x1<<endl;
- float a=sqrt(powf((x2-x1),2)+powf((y2-y1),2)); //cout<<"a: "<<a<<endl;
- float b=sqrt((powf((x3-x2),2)+powf((y3-y2),2))); //cout<<"b: "<<b<<endl;
- float c=sqrt((powf((x1-x3),2)+powf((y1-y3),2))); //cout<<"c: "<<c<<endl;
- float p=((a+b+c)/2); //cout<<"p: "<<p<<endl;
- float s=sqrt((p*(p-a)*(p-b)*(p-c))); //cout<<"s: "<<s<<endl;
- return s;
- }
- void main()
- {
- int x1=-3, x2=-1, x3=0, x4, y1=-1, y2=1, y3=-1, y4;
- //int x1=-1, x2=-1, x3=0, x4, y1=0, y2=-1, y3=-1, y4; //тест работы считалки площади, ответ 0.5
- cout<<"Vvedite x, y:"<<endl;
- cin>>x4>>y4;
- //cout<<"0^1/2="<<powf(0,1/2)<<endl; //pow чёт не пашет, пришлось подключить <cmath> и считать sqrt()
- float S=ploshad(x1,y1,x2,y2,x3,y3);
- float S2=ploshad(x1,y1,x2,y2,x4,y4); //cout<<"S2="<<S2<<endl;
- float S3=ploshad(x1,y1,x3,y3,x4,y4); //cout<<"S3="<<S3<<endl;
- float S4=ploshad(x2,y2,x3,y3,x4,y4); //cout<<"S4="<<S4<<endl;
- float Ssum=S2+S3+S4; //cout<<"Ssum="<<Ssum<<endl<<"S="<<S<<endl;
- if(S>=Ssum)
- {
- cout<<"To4ka lezhit v treugolnike"<<endl;
- }
- else
- {
- cout<<"To4ka ne lezhit v treugolnike"<<endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment