日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

POJ1269 直线相交

發(fā)布時(shí)間:2024/9/21 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 POJ1269 直线相交 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

版子 http://blog.csdn.net/acm_zl/article/details/9471451

#include <iostream> #include <cstdio> #include <string> #include <string.h> #include <map> #include <vector> #include <cstdlib> #include <cmath> #include <algorithm> #include <queue> #include <set> #include <stack> using namespace std; int main() { int t; double x1,y1,x2,y2,x3,y3,x4,y4; scanf("%d", &t); printf("INTERSECTING LINES OUTPUT\n"); while(t--) { scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4); if(x1==x2 && x3==x4)//兩直線都沒(méi)有斜率 { if(x3==x1) printf("LINE\n"); else printf("NONE\n"); } else if(x1==x2 && x3!=x4)//有一條直線斜率存在 { double k = (y4-y3)*1.0/(x4-x3); double b = y3-(k*x3); double ansx = x1; double ansy = k*x1+b; printf("POINT %.2lf %.2lf\n", ansx, ansy); } else if(x1!=x2 && x3==x4)//有一條直線斜率存在 { double k = (y2-y1)*1.0/(x2-x1); double b = y2-(k*x2); double ansx = x3; double ansy = k*x3+b; printf("POINT %.2lf %.2lf\n", ansx, ansy); } else //兩條直線斜率都存在 { double k1 = (y2-y1)*1.0/(x2-x1); double b1 = y2-(k1*x2); double k2 = (y4-y3)*1.0/(x4-x3); double b2 = y3-(k2*x3); if(k1==k2) { if(b1==b2) printf("LINE\n"); else printf("NONE\n"); } else { double ansx = (b1-b2)*1.0/(k2-k1); double ansy = k1*ansx + b1; printf("POINT %.2lf %.2lf\n", ansx, ansy); } } } printf("END OF OUTPUT\n"); return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/nj-czy/p/5867614.html

總結(jié)

以上是生活随笔為你收集整理的POJ1269 直线相交的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。