这题的代码我本想蹭个部分分,没想到过了
#include <bits/stdc++.h>
using namespace std;
int x,y,n,m;
int main(){
cin>>x>>y>>n>>m;
double k=1.0*(y-m)/(x-n);
double b=y-k*x;
if(b==0)cout<<"y="<<k<<"x";
else if(k==0.5){
if(b==0.5)cout<<"y=1/2*x+1/2";
else if(b==-0.5)cout<<"y=1/2*x-1/2";
else cout<<"y=1/2*x+"<<b;
}
else if(k==-0.5){
if(b==0.5)cout<<"y=-1/2*x+1/2";
else if(b==-0.5)cout<<"y=-1/2*x-1/2";
else cout<<"y=1/2*x-"<<b;
}
else cout<<"y="<<k<<"x+"<<b;
return 0;
}
结果就这么过了