• NYOJ 1016 判断两线段是否相交


    #include<cstdio>
    #include<cmath>
    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<stack>
    #include<cstring>
    #include<queue>
    #include<set>
    #include<string>
    #include<map>
    #include <time.h>
    #define PI acos(-1)
    using namespace std;
    typedef long long ll;
    typedef double db;
    const int maxn = 400005+1000;
    const int sigma=26;
    const ll mod = 1000000007;
    const int INF = 0x3f3f3f;
    const db eps = 1e-9;
    struct point {
        db x, y;
        point(db x=0, db y=0):x(x), y(y) {}
    }s1, e1, s2, e2;
    
    typedef point Vector;
    Vector operator - (point A, point B) {
        return Vector(A.x-B.x, A.y-B.y);
    }
    db Cross(point A, point B) {
       return A.x*B.y-B.x*A.y;
    }
    void solve() {
        scanf("%lf%lf%lf%lf", &s1.x, &s1.y, &e1.x, &e1.y);
        scanf("%lf%lf%lf%lf", &s2.x, &s2.y, &e2.x, &e2.y);
        Vector CA=s1-s2;
        Vector CD=e2-s2;
        Vector CB=e1-s2;
        db s=Cross(CA, CD)*Cross(CB, CD);
        Vector AC=s2-s1;
        Vector AB=e1-s1;
        Vector AD=e2-s1;  
        db ss=Cross(AC, AB)*Cross(AD, AB);
       // cout<<s<<" "<<ss<<endl;
        if (s<=0 && ss<=0)  puts("Interseetion");
        else  puts("Not Interseetion");
    }
    int main() {
        int t = 1;
       // freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        scanf("%d", &t);
        while(t--) {
            solve();
        }
        return 0;
    }
  • 相关阅读:
    GDB 用法
    C编程规范
    PHP面向对象
    cron定时任务
    Apatche配置基础
    正则表达式笔记
    PHP在windows下命令行方式
    面试题
    struts与ajax的关系
    ORACLE DUAL表详解
  • 原文地址:https://www.cnblogs.com/gggyt/p/7646605.html
Copyright © 2020-2023  润新知