📄 3v.cpp
字号:
// Program to calculate the height of a tower
#include <iostream.h>
#include <math.h>
// CalcHypot() A function to calc. and return the hypotenuse
// of a right triangle.
// IN: base; the base of the triangle
// angle; an angle in degrees between the base and hypot.
float CalcHypot (float base, float angle)
{ float radians, ht, dist;
const float pi_radians = 0.01745; // pi / 180.0;
radians = angle * pi_radians;
ht = base * tan(radians);
dist = sqrt (base*base + ht*ht);
return (dist);
}
void main()
{ float base, angle, dist;
cout << "enter base distance to tower:";
cin >> base;
cout << "enter angle (in degrees):";
cin >> angle;
dist = CalcHypot (base, angle);
cout << " distance from observer to top: " << dist << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -