用c语言程序写出,输入一个角度值,计算正弦余弦,高手帮忙看看错误
/*Note:YourchoiceisCIDE*/#include"stdio.h"#include"math.h"voidmain(){#defineP...
/* Note:Your choice is C IDE */ #include "stdio.h" #include "math.h" void main() { #define PI 3.1415926; float a,b,c,d,e; printf("请输入角度值:"); scanf("%d",&a); b=PI/180.0*a; /*为啥不行呢?*/ c=sin(b); d=cos(b); printf("正弦值为:%.4f\n",c); printf("余弦值为:%.4f",d); return 0; }
展开
1个回答
展开全部
/*
Note:Your
choice
is
C
IDE
*/
#include
"stdio.h"
#include
"math.h"
#define
PI
3.1415926//把;去掉
void
main()
{
//#define
PI
3.1415926//把;去掉,放到前面去
double
a,b,c,d;//最好改为double型,因为正余弦函数的返回值是double型,e没用到,去掉
printf("请输入角度值:");
scanf("%lf",&a);//将%d改为%lf
b=PI/180.0*a;
/*为啥不行呢?*/
c=sin(b);
d=cos(b);
printf("正弦值为:%.4lf\n",c);
printf("余弦值为:%.4lf",d);
//
return
0;//main函数无返回值,这里不需要
}
Note:Your
choice
is
C
IDE
*/
#include
"stdio.h"
#include
"math.h"
#define
PI
3.1415926//把;去掉
void
main()
{
//#define
PI
3.1415926//把;去掉,放到前面去
double
a,b,c,d;//最好改为double型,因为正余弦函数的返回值是double型,e没用到,去掉
printf("请输入角度值:");
scanf("%lf",&a);//将%d改为%lf
b=PI/180.0*a;
/*为啥不行呢?*/
c=sin(b);
d=cos(b);
printf("正弦值为:%.4lf\n",c);
printf("余弦值为:%.4lf",d);
//
return
0;//main函数无返回值,这里不需要
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询