#include <iostream> using namespace std; int main() { int h = 100; // 初始高度为100米 int total_distance = h; // 总共经过的距离,初始化为初始高度 int height = h; // 当前高度,初始为初始高度 for (int i = 1; i <= 10; i++) { height /= 2; // 反弹到原来高度的一半 total_distance += 2*height; // 经过下落和反弹两次 } cout << "第10次落地时,共经过 " << total_distance << " 米" << endl; cout << "第10次反弹的高度为 " << height << " 米" << endl; return 0; } [2024-12-07 20:03:46 | AI写代码神器 | 338点数解答]