二十九万八千零七十九:编写函数求表达式x2-2x+1的值,x作为参数传递给函数,调用此函数求:

来源:百度文库 编辑:高考问答 时间:2024/05/15 06:21:24
编写函数求表达式x平方-2x+1的值,x作为参数传递给函数,调用此函数求:
y1=3平方-2*3+1
y2=(x+1)平方-2*(x+1)+1
y3=cos平方x-2*cos x+1 的值。

include<stdio.h>
include<math.h>
main()
{float x,y1,y2,y3;
scanf("%f",&x);
float pfh(float x);
y1=pfh(3);
y2=pfh(x+1);
y3=pfh(cosx);
printf("y1=%-8.3f\ny2=%-8.3f\ny3=%-8.3f\n",&y1,&y2,&y3);
}
float pfh(float x)
{float t;
t=x*x-2*x+1;
return t;
}

ExValue(float x)
{
return (x*x-2*x+1);
}

main()
{
printf("%f",ExValue(3));
}

????