阅读背景:

数据结构第一章绪论(例题+课后答案)_Raytheon 1715313189的博客_数据结构第一章课后题答案

来源:互联网 
//例1.5
#include<iostream>
#include<math.h>
using namespace std;
float d, x, x1, x2;
void solution(float a, float b, float c)
{
	d = b * b - 4 * a*c;
	if (d > 0)
	{
		x1 = (-b + sqrt(d)) / (2 * a);
		x2 = (-b - sqrt(d)) / (2 * a);
		cout << "两个实根:" << "x1=" << x1 <<" "<< "x2=" << x2<<endl;
	}
	else if (d == 0)
	{
		x = (-b) / (2 * a);
		cout << "一个实根:" << "x=" << x<<endl;
	}
	else
		cout << "不存在实根"<<endl;
}
int main()
{
	cin >> x >> x1 >> x2;
	solution(x, x1, x2);
}//例1.5
#include<iostream>
#include<math.h>
usin



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: