Chỗ scanf. Chắc luôn.
Với lại viết biểu thức như vậy mà trả về int thì kết quả sẽ bị sai nhé.
(ghi chú: công thức https://stackoverflow.com/questions/15779577/computing-which-side-of-a-line-a-point-is )
Ai biết cho em hỏi như thế này là lỗi gì vậy ạ. Đây là code của em,cảm ơn anh em trước ạ:
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct Node {
int x, y;
};
Node diemphang() {
Node *node;
node = (Node*)malloc(sizeof(Node));
printf("toa do cua diem:");
printf("x:");
scanf_s("%d", node->x);
printf("y:");
scanf_s("%d", node->y);
return *node;
}
int Test(Node n, Node n1, int x1, int y1) {
return (n.x - n1.x) / (x1 - n.x) - (n.y - n1.y) / (y1 - n.y);
}int KiemTra(Node A, Node B, Node C, Node M) {
int a;
a = Test(A, B, M.x, M.y) * Test(B, C, M.x, M.y) * Test(A, C, M.x, M.y);
if (a <= 0) return -1;
else return 0;
}
int main()
{
printf("diem A:");
Node A; A = diemphang();
printf("diem B");
Node B; B = diemphang();
printf("diem C");
Node C; C = diemphang();
printf("Diem M");
Node M; M = diemphang();
if (KiemTra(A, B, C, M) == 0) printf("trong tam giac");
else printf("ngoai tam giac");
_getch();
}
Chỗ scanf. Chắc luôn.
Với lại viết biểu thức như vậy mà trả về int thì kết quả sẽ bị sai nhé.
(ghi chú: công thức https://stackoverflow.com/questions/15779577/computing-which-side-of-a-line-a-point-is )
Đã được chỉnh sửa lần cuối bởi prog10 : 22-11-2016 lúc 10:49 PM.
thank you pro.