1 class Solution 2 { 3 public: 4 bool isBoomerang(vector>& 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 };
也不知道在写什么,加特判加一堆,还好过了