Quipex icon

zadanie_2_XIII

Quipex | PRO | 10/22/15 09:59:51 PM UTC | 0 ⭐ | 269 👁️ | Never ⏰ | []
C++ |

1.6 KB

|

None

|

0 👍

/

0 👎

// zadanie_2_XIII.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
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;
}
 
float perimetr(int x1, int y1, int x2, int y2, int x3, int y3)
{
        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)));
        float p=a+b+c;
        return p;
}
 
int main()
{
    double x_3,x_1,x_2,y_3,y_1,y_2;
    double p,s;
    cout<<"Vvedite x1, y1; x2, y2; x3, y3;\n";
    cin>>x_1>>y_1>>x_2>>y_2>>x_3>>y_3;
    if ((x_3 - x_1)*(y_2 - y_1)  == (y_3 - y_1)*(x_2 - x_1))
    {
        cout<<"tochki lezhat na 1 pryamoj\n";
    }   
    else
    {
        cout<<"\nPloshad="<<ploshad(x_1,y_1,x_2,y_2,x_3,y_3)<<endl;
        cout<<"\nPerimetr="<<perimetr(x_1,y_1,x_2,y_2,x_3,y_3)<<endl;
    }
    cout<<endl;
    system("pause");
    return 0;
}

Comments