0_0_2862792_15061\Main.java:1: ·Ç·¨×Ö·û£º \35
#include<iostream>#include<iomanip>using namespace std; double x1,x2,x3,x4,y1,y2,y3,y4,k1,k2,b1,b2;void xiandeng(){ if((x3*k1+b1)==y3) cout<<"LINE"<<endl; else cout<<"NONE"<<endl;}void xiangjiao(){ double x,y; x=(b2-b1)/(k1-k2); y=(k1*x)+b1; cout<<"POINT "; cout<<fixed<<setprecision(2)<<x;//printf("%.2lf",x); cout<<" "; cout<<fixed<<setprecision(2)<<y;//printf("%.2lf",y); cout<<endl;}int main(){ int n; while(cin>>n) { int i; printf("%s\n","INTERSECTING LINES OUTPUT"); for(i=0;i<n;i++) { cin>>x1>>y1;//scanf("%f%f",&x1,&y1); cin>>x2>>y2;//scanf("%f%f",&x2,&y2); cin>>x3>>y3;//scanf("%f%f",&x3,&y3); cin>>x4>>y4;//scanf("%f%f",&x4,&y4); if(x1!=x2&&x3!=x4) { k1=(y1-y2)/(x1-x2); k2=(y3-y4)/(x3-x4); b1=y1-(k1*x1); b2=y3-(k2*x3); if(k1==k2) { xiandeng(); } if(k1!=k2) xiangjiao(); } if(x1==x2||x3==x4) { if(x1==x2&&x3==x4) { if(x1==x3) cout<<"LINE"<<endl; else cout<<"NONE"<<endl; } if(x1==x2&&x3!=x4) { k2=(y3-y4)/(x3-x4); b2=y3-k2*x3; y1=k2*x1+b2; cout<<"POINT "; cout<<fixed<<setprecision(2)<<x1;//printf("%.2lf",x); cout<<" "; cout<<fixed<<setprecision(2)<<y1;//printf("%.2lf",y); cout<<endl; } if(x1!=x2&&x3==x4) { k1=(y1-y2)/(x1-x2); b1=y1-k1*x1; y3=k1*x3+b1; cout<<"POINT "; cout<<fixed<<setprecision(2)<<x3;//printf("%.2lf",x); cout<<" "; cout<<fixed<<setprecision(2)<<y3;//printf("%.2lf",y); cout<<endl; } } } printf("%s\n","END OF OUTPUT"); } return 0;}
|