⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3v.cpp

📁 C/C++程序设计导论(第二版)》程序源文件
💻 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 + -