正在加载图片...
include <iostream> include <cmath> 调用函数或主调函数 using name space stdi int maino cout < " Enter quadratic coefficients: I double a b, ci cin>> a>>b>>c 被调函数 if((a!=0)&&(b*b-4*a*c>0) 库函数 double radical= sqrt(b*b-4*a*c); double root =(-b radical 2*a); double root (-b radical) (2*a); cout < Roots: < root < ll<< root2 else cout < Does not have two real roots return 0 }2005428 北京邮电大学电信工程学院计算机技术中心2005-4-28 北京邮电大学电信工程学院计算机技术中心 -6- #include <iostream> #include <cmath> using namespace std; int main() { cout << "Enter Quadratic coefficients: "; double a, b, c; cin >> a >> b >> c; if ( (a != 0) && (b*b - 4*a*c > 0) ) { double radical = sqrt(b*b - 4*a*c); double root1 = (-b + radical) / (2*a); double root2 = (-b - radical) / (2*a); cout << "Roots: " << root1 << " " << root2; } else { cout << "Does not have two real roots"; } return 0; } 调用函数 或主调函数 被调函数 库函数
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有