SWUSTOJ #148 陶陶摘苹果

版权声明:知识不设限,可自由转载,请附上连接: https://blog.csdn.net/qq_44475551/article/details/89635328

SWUSTOJ #148 陶陶摘苹果

题目

陶陶家的院子里有一棵苹果树,每到秋天树上就会结出10个苹果。苹果成熟的时候,陶陶就会跑去摘苹果。陶陶有个30厘米高的板凳,当她不能直接用手摘到苹果的时候,就会踩到板凳上再试试。 现在已知10个苹果到地面的高度,以及陶陶把手伸直的时候能够达到的最大高度,请帮陶陶算一下她能够摘到的苹果的数目。假设她碰到苹果,苹果就会掉下来。

输入

输入包括两行数据。第一行包含10个100到200之间(包括100和200)的整数(以厘米为单位)分别表示10个苹果到地面的高度,两个相邻的整数之间用一个空格隔开。第二行只包括一个100到120之间(包含100和120)的整数(以厘米为单位),表示陶陶把手伸直的时候能够达到的最大高度。

输出

输出包括一行,这一行只包含一个整数,表示陶陶能够摘到的苹果的数目。

样例输入

100 200 150 140 129 134 167 198 200 111
110

样例输出

5

源代码

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int one, two, three, four, five, six, seven, eight, nine, ten;
    scanf("%d %d %d %d %d %d %d %d %d %d", &one, &two, &three, &four, &five, &six, &seven, &eight, &nine, &ten);
    int hand;
    scanf("%d", &hand);
    hand += 30;
    int num = 0;
    if(one <= hand)
    {
        num += 1;
    }
    if(two <= hand)
    {
        num += 1;
    }
    if(three <= hand)
    {
        num += 1;
    }if(four <= hand)
    {
        num += 1;
    }if(five <= hand)
    {
        num += 1;
    }if(six <= hand)
    {
        num += 1;
    }if(seven <= hand)
    {
        num += 1;
    }
    if(eight <= hand)
    {
        num += 1;
    }if(nine <= hand)
    {
        num += 1;
    }if(ten <= hand)
    {
        num += 1;
    }
    printf("%d\n", num);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44475551/article/details/89635328