带参宏定义
#include <stdio.h>
#define PI 3.14159
#define PI 3.14159
#define AngleToRadian(d,m,s) ((d) + ((m)+(s)/60)/60)/180*PI
int main()
{
double degree,minute,second;
scanf("%lf %lf %lf",°ree,&minute,&second);
printf("%f",AngleToRadian(degree,minute,second)); /*参数宏会被替换为定义的表达式,算出结果后输出*/
return 0;
}
自定义函数解决
#include <stdio.h>
#define PI 3.14159
#define PI 3.14159
double AngleToRadian(double degree,double minute,double second)
{
minute+=second/60;
degree+=minute/60;
return degree/180*PI;
}
int main()
{
double degree,minute,second;
scanf("%lf %lf %lf",°ree,&minute,&second);
printf("%f",AngleToRadian(degree,minute,second)); /*参数宏会被替换为定义的表达式,算出结果后输出*/
return 0;
}