先上伪代码read apple_heights from input 读取苹果高度列表
read reach_height from input 读取陶陶手伸直能达到的最大高度
bench_height = 30 板凳高度
total_apples = 10 苹果总数
reachable_apples = 0 能摘到的苹果数量
for each height in apple_heights do
if height <= reach_height + bench_height then
reachable_apples = reachable_apples + 1
print reachable_apples 输出能摘到的苹果数量
上代码:#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> apple_heights;
int reach_height, bench_height = 30, reachable_apples = 0;
}