文章
37
粉丝
1
获赞
353
访问
24.6k
克拉默法则
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x1,y1,x2,y2,x3,y3,x4,y4;
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
int A1 = y2-y1;
int B1 = x1-x2;
int C1 = x1*y2-x2*y1;
int A2 = y4-y3;
int B2 = x3-x4;
int C2 = x3*y4-x4*y3;
int D = A1*B2 - A2*B1;
if(D==0){
cout<<"Parallel or coincident"<<endl;
}
else{
int X = C1*B2-C2*B1;
int Y = A1*C2-A2*C1;
double ans1 = (double)X/D;
double ans2 = (double)Y/D;
printf("%.2f %.2f\n",ans1,ans2);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发