| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

已结贴   问题点数：1  回复次数：6

得分:0

得分:0

得分:0

#include <iostream>
using namespace std;
double f (double x,double a0,double a1=0,double a2=0,double a3=0)
{
return a0+a1*x+a2*x*x+a3*x*x*x;
}
int main()
{
int n;double x,a0,a1,a2,a3,A[4];
cin>>x>>n;
for(int i=1;i<=n+1;i++)
cin>>A[i];
cout<<f(x,a0,a1,a2,a3);
return 0;
}

得分:1
for(int i=1;i<=n+1;i++)

#include <iostream>
using namespace std;

double f( double x, double a0, double a1=0, double a2=0, double a3=0 )
{
return a0+a1*x+a2*x*x+a3*x*x*x;
}

int main( void )
{
double x;
size_t n;
cin >> x >> n;

double a[4] = {};
for( size_t i=0; i!=n+1; ++i )
cin >> a[i];

cout << f(x,a[0],a[1],a[2],a[3]) << endl;
}

#include <iostream>
using namespace std;

double fun( double x, double a0, double a1=0, double a2=0, double a3=0 )
{
return a0+a1*x+a2*x*x+a3*x*x*x;
}

int main( void )
{
double x;
size_t n;
cin >> x >> n;

double a0, a1, a2, a3;
if( n == 0 )
{
cin >> a0;
cout << fun(x,a0) << endl;
}
else if( n == 1 )
{
cin >> a0 >> a1;
cout << fun(x,a0,a1) << endl;
}
else if( n == 2 )
{
cin >> a0 >> a1 >> a2;
cout << fun(x,a0,a1,a2) << endl;
}
else if( n == 3 )
{
cin >> a0 >> a1 >> a2 >> a3;
cout << fun(x,a0,a1,a2,a3) << endl;
}
}

得分:0

Thank you very much!
得分:0

Thank you very much!

• 7
• 1/1页
• 1