求M_PI的头文件
VC++6.0环境里的,以为是在math.h中,但没有
自己编的只有用宏定义#define M_PI来表示3.14
#include<stdio.h>
#include<math.h>
#include<ctype.h>
#include<conio.h>
double ssin(float a);
double ccos(float a);
double ttan(float a);
#define M_PI 3.14
int main()
{
float a;
double b,d,e;
char c;
printf("\n此程序用于计算三角函数");
do
{
printf("\n请输入角度:");
fflush(stdin);
scanf("%f",&a);
b=ssin(a);
d=ccos(a);
e=ttan(a);
printf("\nsin%1.2f=%1.2f",a,b);
printf("\ncos%1.2f=%1.2f",a,d);
printf("\ntan%1.2f=%1.2f",a,e);
printf("\n是否继续?(y/n):");
fflush(stdin);
scanf("%c",&c);
}while(toupper(c)=='Y');
printf("\n程序结束,按任意键程序关闭!\n");
getch();
return 0;
}
double ssin(float a)
{
return sin(M_PI/180.0*a);
}
double ccos(float a)
{
return cos(M_PI/180.0*a);
}
double ttan(float a)
{
return tan(M_PI/180.0*a);
}
如果去掉#define M_PI 3.14
程序就出错啦,显示M_PI无定义
但按道理说M_PI在math.h中已经定义了哈