标签:== clu oat 16px while div 实例 font include
多组数据,每组数据为两行,包含8个整数,分别表示四个坐标,(X1,Y1)至(X4,Y4),0<=Xi,Yi<=1000,前两个坐标和后两个坐标分别确定一条直线,计算这两条直线是否相交?
Output:
两条直线若相交,输出Yes,若不相交,输出No,每个实例输出为一行
Sample Input:
1 1 2 2 2 1 3 2 1 1 2 2 2 1 3 3
No Yes
代码:
#include<stdio.h> void main() { float x1,y1,x2,y2,x3,y3,x4,y4; float k1,k2,b1,b2; while(scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF) { k1=(y2-y1)/(x2-x1); k2=(y4-y3)/(x4-x3); b1=y1-k1*x1; b2=y3-k2*x3; if(x1==x2&&x3==x4) { if(x1==x3) printf("Yes\n"); else printf("No\n"); } else { if(k1==k2&&b1!=b2) printf("No\n"); else printf("Yes\n"); } } }
标签:== clu oat 16px while div 实例 font include
原文地址:https://www.cnblogs.com/Zhuohome/p/12823476.html