|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
输入一个角度判断是否是tan90°和270°。
因为tan90°和270°是不存在的正切值。必须提示你90°和270°不存在
现包含MathApply.h头文件
- // This Math Apply header file
- #pragma once
- #include <stdlib.h>
- #include <math.h>
- #ifndef _MATH_H
- #define _MATH_H 0x01
- #define M_PI 3.14159265358979323846
- #define RAD 180 // 弧度
- #define DRE30 0.52359877559829881566 // 30°
- #define DRE45 0.78539816339744827900 // 45°
- #define DRE60 1.04719755119659763132 // 60°
- #define DRE90 1.57079632679489655800 // 90°
- #define DRE180 3.14159265358979311600 // 180°
- #define DRE270 4.71238898038468967400 // 270°
- #define DRE360 6.28318530717958623200 // 360°
- // 角度集合
- int MathDregess[] = { DRE30, DRE45, DRE60, DRE90, DRE180, DRE270, DRE360 };
- /*
- * 度数转小数
- * 1°=pi/180 rad=3.141592653589793/180=0.01745329252
- * 度数 乘 π 除 弧度 = 小数
- */
- #define DregreeToDecimal( DRE ) \
- (DRE * M_PI / RAD)
- #endif
复制代码
- #include <stdio.h>
- #include "MathApply.h"
- int main ( int argc, char *argv [] )
- {
- double expression,
- degress;
- printf("Please input degrees: "); // 接受用户输入,角度数。
- scanf("%lf", °ress);
- expression = tan(DregreeToDecimal(degress));
- if ( expression == tan(DRE90) ||
- expression == tan(DRE270) ) // 判断是否是90°和270°的角
- {
- printf("tangent 90 degress And degress 270 is not exist!\n");
- }
- else
- {
- printf("tan(%0.2lf) = %0.15lf\n", degress, expression);
- }
- return 0;
- }
复制代码 |
|