CSP历年复赛题-P1046 [NOIP2005 普及组] 陶陶摘苹果

原题链接:https://www.luogu.com.cn/problem/P1046

题意解读:30+伸手的高度,能够得着几个苹果。

解题思路:直接模拟。

100分代码:

#include <bits/stdc++.h>
using namespace std;

int a[15], h, ans;

int main()
{
    for(int i = 1; i <= 10; i++) cin >> a[i];
    cin >> h;
    for(int i = 1; i <= 10; i++)
    {
        if(h + 30 >= a[i]) ans++;
    }
    cout << ans;

    return 0;
}

 

posted @ 2024-05-23 13:12  五月江城  阅读(12)  评论(0编辑  收藏  举报