是个三角函数的编程 求sinx he cosx的 #includ "math.h" main() { int a,b,x; printf("please enter one float \"); scanf("%f",&d); a=sinx; b=cosx; ~~~~就是这个地方错了 但不知道错哪了 printf("sinx=%f",a;"cosx=%f",b); }
/*
程序错的地方都有标注,好好看看吧。
*/
#include "stdio。h" /*1。要用printf函数就要加上这个头文件*/
#include "math。
h"
main()
{
double a,b,x; /*2。求sin,cos的时候最好用double*/
printf("please enter one float number:\n");
scanf("%f",&x); /*3。
&d应为&x,否则就要在声明中加上double d;*/
a=sin(x); /*4。sinx不对,sin是函数,应该是sin(x)*/
b=cos(x);/*5。
cosx不对,cos是函数,应该是cos(x)*/
printf("sinx=%f cosx=%f",a,b); /*6。 正确的输出格式应该是这样的*/
}
。
scanf("%f",&d); 有问题,应该改为 scanf("%f",&x); 这样才能把你输入的数值赋给X
你把一个实型数据赋值给整型了,定义a,b的时候应该是 float a,b;