falling.cpp
来自「C/C++程序设计导论(第二版)》程序源文件」· C++ 代码 · 共 27 行
CPP
27 行
// falling.cpp Calculate a victim's altitude each second after a fall // from a given height#include <iostream.h>#include <math.h>const float GRAVITY=32.0;void FallTable (float h){ float time, altitude; time = 0.0; altitude = h; while (altitude > 0.0) { time = time + 1.0; altitude = h - GRAVITY * time * time / 2.0; cout << "time: " << time << " altitude: " << altitude << endl; }}void main(){ float height; cout << "Enter building height: "; cin >> height; FallTable(height); cout << "done." << endl;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?