📄 quadeq.cpp
字号:
#include <iostream.h>
#include <math.h>
using namespace std;
int main()
{
cout << "\n\tAX^2+BX+C=0\n";
cout << "\t Quadratic equation\n"; // < i think it's called
/* AX^2+BX+C=0
x= (-b +- sqrt(b^2-4ac))/2a sqrt=square root
*/
float a,b,c,d,x;
cout << "A:";
cin >> a;
cout << "\nB:";
cin >> b;
cout << "\nC:";
cin >> c;
d=b*b-(4*a*c);
if(d<0)
{
cout << "\nNo solution";
}
else
{
x= (-b)/(2*a);
}
if(d==0)
{
cout << "\nX="<<x;
}
if(d>0)
{
x=(-b+ sqrt(d) )/(2*a); // sqrt=square root
cout << "\nX1 = "<< x;
x=(-b- sqrt(d) )/(2*a);
cout << "\nX2 = "<< x;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -