#include #include #include int solution(int** dots, size_t dots_rows, size_t dots_cols) { int pair[3][4] = {{0, 1, 2, 3}, {0, 2, 1, 3}, {0, 3, 1, 2}}; for(int i=0; i<3; i++) { double x1 = (double)dots[pair[i][0]][0], y1 = (double)dots[pair[i][0]][1]; double x2 = (double)dots[pair[i][1]][0], y2 = (double)dots[pair[i][1]][1]; double x3 = (double)dots[pair[i][2]][0], y3 = (double)dots[pair[i][2]][1]; double x4 = (double)dots[pair[i][3]][0], y4 = (double)dots[pair[i][3]][1]; double grad1 = (x2 - x1) / (y2 - y1); double grad2 = (x4 - x3) / (y4 - y3); if(grad1 == grad2) return 1; } return 0; } int main() { int** dots1 = (int**)malloc(sizeof(int*) * 4); int** dots2 = (int**)malloc(sizeof(int*) * 4); for(int i=0; i<4; i++) { dots1[i] = (int*)malloc(sizeof(int) * 2); dots2[i] = (int*)malloc(sizeof(int) * 2); } dots1[0][0] = 1; dots1[0][1] = 4; dots1[1][0] = 9; dots1[1][1] = 2; dots1[2][0] = 3; dots1[2][1] = 8; dots1[3][0] = 11; dots1[3][1] = 6; dots2[0][0] = 3; dots2[0][1] = 5; dots2[1][0] = 4; dots2[1][1] = 1; dots2[2][0] = 2; dots2[2][1] = 4; dots2[3][0] = 5; dots2[3][1] = 0; printf("%d %d\n",solution(dots1, 4, 2) ,solution(dots2, 4, 2)); for(int i=0; i<4; i++) { free(dots1[i]); free(dots2[i]); } free(dots1); free(dots2); return 0; }