作业帮 > 综合 > 作业

C语言填充程序 对x=1,2,3……,10,求f(x)=x*x-5*x+sin(x)的最大值

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/07/23 05:51:14
C语言填充程序 对x=1,2,3……,10,求f(x)=x*x-5*x+sin(x)的最大值
#include
#include
#define f(x) x*x-5*x+sin(x)
void main()
{int x;float max;
___________
for(x=2;x
C语言填充程序 对x=1,2,3……,10,求f(x)=x*x-5*x+sin(x)的最大值
第一个空:max = sin(1.0f);
第二个空:max = max > f((float)x) ? f((float)x): max;
我前面那两位仁兄的程序都无法运行,因为sin函数中的重载中,形参没有int型,需要强转成float型,不信楼主可以用vs试一下.