第五题:
#include<iostream>
#include<cmath>
using namespace std;
class Point
{
public:
double x;
double y;
void print()
{
cout<<"交点为:("<<x<<" , "<<y<<")"<<endl;
}
};
class Line
{
public:
double a,b;
void print()
{
cout<<"y="<<a<<"x+"<<b<<endl;
}
};
class setPoint
{
public:
Line L1;
Line L2;
Point p;
void pp(double a1,double b1,double a2,double b2)
{
L1.a=a1;
L1.b=b1;
L2.a=a2;
L2.b=b2;
p.x=(b2-b1)*1.0/(a1-a2);
p.y=a1*p.x+b1;
}
};
int main()
{
setPoint m;
int a1,b1,a2,b2;
cout<<"请输入两个方程的系数:";
cin>>a1>>b1>>a2>>b2;
m.pp(a1,b1,a2,b2);
m.L1.print();
m.L2.print();
m.p.print();
return 0;
}