C语言填空:宏应用

//功能:对=1,2,3,4,5,6,..,9,10
//求f(x)=x*x-5*x=sin(x)的最大值 并保留两位小数 
#include <stdio.h>1】
【2】 f(x) x*x-5*x+sin(x)
main( )
{ 
    int x;float max;
    max=【3】;
    for(x=2;x<=10;x++)
    if(【4】) max=f(x);
    printf("max=【5】",max);
}
//功能:对=1,2,3,4,5,6,..,9,10
//求f(x)=x*x-5*x=sin(x)的最大值 并保留两位小数 
#include <stdio.h>
#include <math.h>
#define f(x) x*x-5*x+sin(x)
main( )
{ 
    int x;float max;
    max=f(1);
    for(x=2;x<=10;x++)
    if(f(x)>max) max=f(x);
    printf("max=%.2f",max);
}

 

posted @ 2023-02-08 19:36  myrj  阅读(51)  评论(0)    收藏  举报