Quipex

zadanie_2_XIII

Oct 22nd, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. // zadanie_2_XIII.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. float ploshad(int x1, int y1, int x2, int y2, int x3, int y3)
  9. {
  10.                                                                                                                 //cout<<"x: "<<x1<<endl;
  11.         float a=sqrt(powf((x2-x1),2)+powf((y2-y1),2));          //cout<<"a: "<<a<<endl;
  12.         float b=sqrt((powf((x3-x2),2)+powf((y3-y2),2)));        //cout<<"b: "<<b<<endl;
  13.         float c=sqrt((powf((x1-x3),2)+powf((y1-y3),2)));        //cout<<"c: "<<c<<endl;
  14.         float p=((a+b+c)/2);                                                            //cout<<"p: "<<p<<endl;
  15.         float s=sqrt((p*(p-a)*(p-b)*(p-c)));                            //cout<<"s: "<<s<<endl;
  16.        
  17.         return s;
  18. }
  19.  
  20. float perimetr(int x1, int y1, int x2, int y2, int x3, int y3)
  21. {
  22.         float a=sqrt(powf((x2-x1),2)+powf((y2-y1),2));          //cout<<"a: "<<a<<endl;
  23.         float b=sqrt((powf((x3-x2),2)+powf((y3-y2),2)));        //cout<<"b: "<<b<<endl;
  24.         float c=sqrt((powf((x1-x3),2)+powf((y1-y3),2)));
  25.         float p=a+b+c;
  26.         return p;
  27. }
  28.  
  29. int main()
  30. {
  31.     double x_3,x_1,x_2,y_3,y_1,y_2;
  32.     double p,s;
  33.     cout<<"Vvedite x1, y1; x2, y2; x3, y3;\n";
  34.     cin>>x_1>>y_1>>x_2>>y_2>>x_3>>y_3;
  35.     if ((x_3 - x_1)*(y_2 - y_1)  == (y_3 - y_1)*(x_2 - x_1))
  36.     {
  37.         cout<<"tochki lezhat na 1 pryamoj\n";
  38.     }  
  39.     else
  40.     {
  41.         cout<<"\nPloshad="<<ploshad(x_1,y_1,x_2,y_2,x_3,y_3)<<endl;
  42.         cout<<"\nPerimetr="<<perimetr(x_1,y_1,x_2,y_2,x_3,y_3)<<endl;
  43.     }
  44.     cout<<endl;
  45.     system("pause");
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment