求助20分

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

_TheCat @ 2024-05-12 07:56:21

#include<iostream>
using namespace std;
int apples[19],s,tall;
int main(){
    for(int i=1;i<=10;i++) scanf("%d",apples+i);
    cin>>tall;
    for(int i=1;i<=10;i++){
        if(tall>=apples[i]-10) s++;
    }
    cout<<s;
    return 0;
}

by Chu_awa_xing @ 2024-05-12 08:12:53

板凳高30厘米不是10厘米,也就是第八行的减10改成减30

 if(tall>=apples[i]-10) s++;

by COKENOTFOUND @ 2024-05-12 08:13:39

@ProgrammingCat

if(tall>=apples[i]-10)

应该为

if(tall>=apples[i]-30)

by yhcorey @ 2024-05-12 08:21:59

#include<iostream>

应该为

#include<bits/stdc++.h>

by NullPointerExpection @ 2024-05-18 15:21:40

@yhcorey 这个不重要


by xiayihe000 @ 2024-06-01 20:49:07

@ProgrammingCat


#include <iostream>
using namespace std;

int n, cnt;
int arr[11];

int main()
{
    for(int i = 0;i < 10;i++)
    {
        cin >> arr[i];
    }

    cin >> n;

    for(int i = 0;i < 10;i++)
    {
        if(n >= arr[i])
        {
            cnt++;
        }
        else if(n + 30 >= arr[i])
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

by 66666s @ 2024-06-06 13:10:59

@小夏2013 .............. 小心被封


by xiayihe000 @ 2024-06-09 23:12:17

@66666s 谢谢提醒


|