久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

1.編寫一個求方程ax2 + bx + c = 0的根 的程序,用3個函數(shù)分別求當b2-4ac大于零,、等于零,、和小于零時的方程的根。要求從主函數(shù)輸入a,b,c的值并輸出結(jié)果,。

 木俊 2018-06-13

#include"iostream"
using namespace std;
void save1(int a, int b, int c);
void save2(int a, int b, int c);
void save3(int a, int b, int c);
int main()
{
 cout << "求解Ax^2+Bx+C=0的解" << endl;
 cout << "please input A  B  C" << endl;
 cout << "輸入一個參數(shù)后,,請按回車鍵" << endl;
 cout << "input A:";
 int A; cin >> A; cout << endl;
 cout << "input B:";
 int B; cin >> B; cout << endl;
 cout << "input C:";
 int C; cin >> C; cout << endl;
 int temp = B * B - 4 * A*C;
 if (temp < 0)
 {
  save1(A,B,C);
 }
 if (temp ==0)
 {
  save2(A, B, C);
 }
 if (temp > 0)
 {
  save3(A, B, C);
 }
 
 system("pause");
 return 0;
}
void save3(int a, int b, int c)
{
 double temp = b * b - 4 * a*c;
 double tenp1 = sqrt(temp);
 double x = (-b + tenp1) / 2 * a;
 double x1 = -x;
 cout << "第一個解" << x << endl;
 cout << "第二個解" << x1 << endl;
}
void save2(int a, int b, int c)
{
 double temp = b * b - 4 * a*c;
 double tenp1 = sqrt(temp);
 double x = (-b + tenp1) / 2 * a;
 cout << "一個解" << x << endl;
}
void save1(int a, int b, int c)
{
 double temp, real1, real2, image1, image2;
 temp = -(b*b - 4 * a * c);
 real1 = -b / (2 * a *1.0);
 real2 = real1;
 image1 = sqrt(temp);
 image2 = -image1;
 cout << "兩個虛根" << endl;
 cout << "x1 = " << real1 << " + " << image1 << "j" << endl;
 cout << "x2 = " << real2 << image2 << "j" << endl;

}

 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多