📄 1248.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1248 on 2005-09-25 at 20:52:35 */
#include <stdio.h>
int main()
{
int test, i, j;
int x[4], y[4];
long subx[2], suby[2], m, c[2];
double cx, cy;
while(scanf("%d", &test) == 1) {
printf("INTERSECTING LINES OUTPUT\n");
for(i = 0; i < test; i++) {
for(j = 0; j < 4; j++) {
scanf("%d %d", &x[j], &y[j]);
}
subx[0] = x[1] - x[0];
suby[0] = y[1] - y[0];
subx[1] = x[3] - x[2];
suby[1] = y[3] - y[2];
m = subx[0] * suby[1] - subx[1] * suby[0];
if(m == 0) {
subx[0] = x[2] - x[0];
suby[0] = y[2] - y[0];
if(subx[0] * suby[1] == subx[1] * suby[0]) {
printf("LINE\n");
} else {
printf("NONE\n");
}
} else {
c[0] = suby[0] * x[0] - subx[0] * y[0];
c[1] = suby[1] * x[2] - subx[1] * y[2];
cx = (double)(subx[0] * c[1] - subx[1] * c[0]) / m;
cy = (double)(suby[0] * c[1] - suby[1] * c[0]) / m;
printf("POINT %.2lf %.2lf\n", cx, cy);
}
}
printf("END OF OUTPUT\n");
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -