1.3 编程基础之算术表达式与顺序执行 07 计算多项式的值

http://noi.openjudge.cn/ch0103/07/

#include<iostream>
using namespace std;
int main()
{
	double a,b,c,d,x,f;
	
	cin>>x>>a>>b>>c>>d;
	
	f=a*x*x*x+b*x*x+c*x+d;
	
	printf("%.7lf\n",f);
	//cout<<f<<endl; 
	
	return 0;
} 

 


 

 


python3代码

"""
1.3编程基础之算术表达式与顺序执行 07 计算多项式的值
http://noi.openjudge.cn/ch0103/07/

"""
x, a, b, c, d = map(float, input().split())
result = a*x*x*x + b*x*x + c*x + d
print('%.7f' % result)

 

おすすめ

転載: blog.csdn.net/dllglvzhenfeng/article/details/121911956