Advertisement
Nexon

Untitled

Dec 9th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. void main() {
  8.     setlocale(LC_ALL, "Russian");
  9.  
  10.     double circle_y = 3.0;
  11.     double circle_x = -7.0;
  12.     double circle_r = 3.0;
  13.     double triangle_v1_x = 0.0;
  14.     double triangle_v1_y = 0.0;
  15.     double triangle_v2_x = -5.0;
  16.     double triangle_v2_y = 0.0;
  17.     double triangle_v3_x = 0.0;
  18.     double triangle_v3_y = 6.0;
  19.     double point_x;
  20.     double point_y;
  21.     double s,s1,s2,s3;
  22.  
  23.     cout<<"Введите X: ";
  24.     cin>>point_x;
  25.     cout<<endl;
  26.  
  27.     cout<<"Введите Y: ";
  28.     cin>>point_y;
  29.     cout<<endl;
  30.  
  31.     s = 0.5*fabs((triangle_v1_x - triangle_v3_x)*(triangle_v2_y - triangle_v3_y) - (triangle_v2_x - triangle_v3_x)*(triangle_v1_y - triangle_v3_y));
  32.     s1 = 0.5*fabs((point_x - triangle_v3_x)*(triangle_v2_y - triangle_v3_y) - (triangle_v2_x - triangle_v3_x)*(point_y - triangle_v3_y));
  33.     s2 = 0.5*fabs((triangle_v1_x - triangle_v3_x)*(point_y - triangle_v3_y) - (point_x - triangle_v3_x)*(triangle_v1_y - triangle_v3_y));
  34.     s3 = 0.5*fabs((triangle_v1_x - point_x)*(triangle_v2_y - point_y) - (triangle_v2_x - point_x)*(triangle_v1_y - point_y));
  35.  
  36.     if(s == (s1+s2+s3) || (pow((point_y - circle_y), 2.0) + pow((point_x - circle_x), 2.0)) <= pow(circle_r, 2.0))cout<<"Принадлежит"<<endl;else cout<<"Не принадлежит"<<endl;
  37.  
  38.     system("PAUSE");
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement