函数的使用与说明
•
程序代码
Database & Information System Lab
#include<iostream>//program5-1
#include<cmath>//use function sqrt
using namespace std;
void main(void){
float p, q, xr;
cout<<″Input parameters: p=″;
cin>>P;
cout<<″Input parameters: q=″;
cin>>q;
cout<<"The Equation is:";
cout<<"x
3
+"<<p<<"x+"<<q<<"=0"<<endl;
float a=sqrt ((q/2)*(q/2) + (q/3) * (q/3) * (q/3));
float R,S,A,B;
const float eps = 1e-6;// 设置精确度
R = -q/2+a;
S = -q/2-a;
第 4 页 / 共 257 页
评论0