首页 > 其他 > 详细

poj 1269

时间:2019-02-27 21:17:17      阅读:171      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
const int maxn=1e6+10;
const double EXP=1e-9;
struct point  { ll x,y;};
struct segment{ point a,b; }pa[maxn];
struct line   { point a,b; line(point x,point y){ a=x,b=y; };   };;
int main()
{
    int T;scanf("%d",&T);
    printf("INTERSECTING LINES OUTPUT\n");
    while(T--)
    {
        point a,b,c,d;
        scanf("%lld %lld %lld %lld",&a.x,&a.y,&b.x,&b.y);
        scanf("%lld %lld %lld %lld",&c.x,&c.y,&d.x,&d.y);
        ll A1=b.y-a.y,B1=-(b.x-a.x),C1=b.y*a.x-b.x*a.y;
        ll A2=d.y-c.y,B2=-(d.x-c.x),C2=d.y*c.x-d.x*c.y;
        ll k=A1*B2-A2*B1;
        if(k==0)
        {
            if( C2*A1-C1*A2==0 && B1*C2-C1*B2==0 ) printf("LINE\n");
            else                   printf("NONE\n");
        }
        else
        {
            double x=-(B1*C2-C1*B2)*1.000000000/k;
            double y=(A1*C2-C1*A2)*1.00000000/k;
            printf("POINT %.2f %.2f\n",x,y);
        }
    }
    printf("END OF OUTPUT\n");
    return 0;
}

 

poj 1269

原文:https://www.cnblogs.com/Andromeda-Galaxy/p/10446804.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!