Advertisement
Hippskill

Untitled

Jan 19th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include<stdio.h>
  3. #include<iostream>
  4. #include<vector>
  5. #include<cmath>
  6. #include<algorithm>
  7. #include<memory.h>
  8. #include<map>
  9. #include<set>
  10. #include<queue>
  11. #include<list>
  12. #include<sstream>
  13. #include<cstring>
  14. #include<numeric>
  15. #include<limits.h>
  16. using namespace std;
  17.  
  18.  
  19. struct point {
  20. private: double x, y;
  21. public:
  22.     point() : x(0), y(0) {}
  23.     point(double x, double y) : x(x), y(y) {}
  24.  
  25.     void scan() {
  26.         scanf("%lf%lf", &x, &y);
  27.     }
  28.     point operator+ (const point & P) const {
  29.         return point(x + P.x, y + P.y);
  30.     }
  31.  
  32.     point operator- (const point & P) const {
  33.         return point(x - P.x, y - P.y);
  34.     }
  35.  
  36.     point operator/ (double k) const {
  37.         return point(x / k, y / k);
  38.     }
  39.  
  40.     double operator*(const point & p) const {
  41.         return x * p.y - y * p.x;
  42.     }
  43.  
  44. };
  45.  
  46. double triangleArea(point & A, point & B, point & C) {
  47.     return abs((A - B) * (C - B)) * 0.5;
  48. }
  49.  
  50.  
  51. double triangleArea(point & A, point & B, point & C) {
  52.     return abs((A - B) * (C - B)) * 0.5;
  53. }
  54.  
  55.  
  56. point f[3];
  57. point s[3];
  58.  
  59. int main(){
  60.     for (int i = 0; i < 3; i++) {
  61.         f[i].scan();
  62.     }
  63.    
  64.     for (int i = 0; i < 3; i++) {
  65.         s[i].scan();
  66.     }
  67.  
  68.     double fs = triangleArea(f[0], f[1], f[2]);
  69.     double ss = triangleArea(s[0], s[1], s[2]);
  70.  
  71.     if (fs != ss) {
  72.         printf("5");
  73.         return 0;
  74.     }
  75.  
  76.     return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement