70061 - 2025青少年编程挑战赛入门组完善1
统计题目(材料题)
跳跃游戏 青蛙在河边玩跳跃游戏,河中有n个石头排成一排,每个石头上标有一个数字表示从这个石头最多可以跳几步。例如数字是3,就可以跳1、2或3步。青蛙从第一个石头出发,问它能否跳到最后一个石头?
试补全程序:
01 #include <iostream>
02 using namespace std;
03 int stones[100000];
04
05 int main() {
06 int n;
07 cin >> n;
08 for (int i = 1; i <= n; i++)
09 cin >> stones[i];
10 int max_distance = ① ;
11 bool Reach = false;
12 for (int i = 1; i <= n; ++i) {
13 if ( ② ) {
14 Reach = false;
15 break;
16 }
17 if ( ③ ) {
18 ④ ;
19 }
20 if ( ⑤ ) {
21 Reach = true;
22 break;
23 }
24 }
25 cout << (Reach ? "Yes" : "No") << endl;
26 return 0;
27 }
||

关注我们