90分,最后一个点错了

P1046 [NOIP2005 普及组] 陶陶摘苹果

Grace_Stock @ 2017-08-20 20:25:05

#include<iostream>
using namespace std;
int apple[10];
int main()
{
    int tall;
    for (int i=0;i<10;i++){
        cin>>apple[i];
    }
    cin>>tall;
    int max=tall+30,n=0;
    for (int i=0;i<10;i++){
        if (apple[i]<max) n++;
    }
    cout<<n;
}

by Hcf2002 @ 2017-08-20 20:28:17

假设她碰到苹果,苹果就会掉下来。


by redbull @ 2017-08-20 20:35:58

for(int i=0;i<10;i++)

if(apple[i]<=max) n++;

是<=不是<


by Grace_Stock @ 2017-08-20 20:44:34

@ChrisHuang @lzssss 谢谢,已通过


by 小孙昕 @ 2017-08-21 13:41:41

var
a,b,c:longint;
x:array[1..10] of longint;
begin
for a:=1 to 10 do
read(x[a]);
readln;
read(b);
for a:=1 to 10 do
if x[a]<=b+30 then c:=c+1;
write(c);
end.

by litianqi2529298200 @ 2017-08-24 16:20:50

#include <iostream>
using namespace std;
int height[20],H,s;
int main()
{
    for(int i=0;i<10;i++)cin >> height[i];
    cin >> H; //假设她碰到苹果,苹果就会掉下来!
    H += 30;
    for(int i=0;i<10;i++)s+=!(H<height[i]);
    cout << s;
}

|