⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8_73.cpp

📁 书记所附的小程序
💻 CPP
字号:
#include<iostream.h>
class line
{
	double k,b;
	friend class process;
public:
	line(double kk,double bb)
	{
		k=kk;
		b=bb;
	}
	void print()
	{
		cout<<"y=("<<k<<")*x+("<<b<<")"<<endl;
	}
};
struct point
{
	double x;
	double y;
};
class process
{
    point point1;
public:
	point setpoint(line& p,line& q)
	{
		point1.x=(q.b-p.b)/(p.k-q.k);
		point1.y=(p.k*q.b-q.k*p.b)/(p.k-q.k);
		return point1;
	}
	void disp(point &s)
	{
		cout<<"两直线交点为:("<<s.x<<","<<s.y<<")."<<endl;
	}
	point getpoint(){return point1;}
};

void main()
{
	double slope1,slope2,section1,section2;
	cout<<"请输入第一条直线的斜率:";
	cin>>slope1;
    cout<<"请输入第一条直线的截距:";
    cin>>section1;
	cout<<"请输入第二条直线的斜率:";
	cin>>slope2;
    cout<<"请输入第二条直线的截距:";
	cin>>section2;
    line line1(slope1,section1),line2(slope2,section2);
	cout<<"直线方程为:"<<endl;
	line1.print();
	line2.print();
	process p1,p2;
	p1.setpoint(line1,line2);
	p2.disp(p1.getpoint());
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -