首页 > 其他 > 详细

Leetcode-5051 Valid Boomerang(有效的回旋镖)

时间:2019-05-05 12:51:28      阅读:138      评论:0      收藏:0      [点我收藏+]
 1 class Solution
 2 {
 3     public:
 4         bool isBoomerang(vector<vector<int>>& points)
 5         {
 6             if(points[0][0] == points[1][0] && points[0][1] == points[1][1]
 7               || points[1][0] == points[2][0] && points[1][1] == points[2][1]
 8               ||points[0][0] == points[2][0] && points[0][1] == points[2][1]
 9               || points[0][0] == points[1][0] && points[1][0] == points[2][0]
10               || points[0][1] == points[1][1] && points[1][1] == points[2][1])
11             return false;
12             double a = (double)(points[0][0] - points[1][0]) / (points[0][1] - points[1][1]);
13             double b = (double)(points[1][0] - points[2][0]) / (points[1][1] - points[2][1]);
14             double c = (double)(points[0][0] - points[2][0]) / (points[0][1] - points[2][1]);
15 
16             if(abs(a-b)<1e-3 && abs(a-c)<1e-3)
17                 return false;
18             return true;
19         }
20 };

也不知道在写什么,加特判加一堆,还好过了

Leetcode-5051 Valid Boomerang(有效的回旋镖)

原文:https://www.cnblogs.com/Asurudo/p/10812273.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!