Skip to content

Commit

Permalink
이슈 #394에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
1 parent 7954243 commit 2b32bd3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Programmers/평행.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <string>
#include <vector>

using namespace std;

double calculateSlope(const vector<int>& point1, const vector<int>& point2) {
return static_cast<double>(point2[1] - point1[1]) / (point2[0] - point1[0]);
}

int solution(vector<vector<int>> dots) {
if (calculateSlope(dots[0], dots[1]) == calculateSlope(dots[2], dots[3])) return 1;
if (calculateSlope(dots[0], dots[2]) == calculateSlope(dots[1], dots[3])) return 1;
if (calculateSlope(dots[0], dots[3]) == calculateSlope(dots[1], dots[2])) return 1;

return 0;
}

0 comments on commit 2b32bd3

Please sign in to comment.