蒟蒻求解!!!

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

zgr0712 @ 2024-06-27 20:26:01

本蒟蒻求dalao指点一下下面的代码哪里错了(只得了10分

#include <iostream>
using namespace std;
int main()
{
    int a[10],b,c;
    for(int i = 0;i < 9;i++)
    {
        cin>>a[i];
    }
    cin>>b;
    c = b+30;
    int aa = 0;
    for(int i=0;i<10;i++){
        if(a[i] <= c)
        {
            aa++;
        }

    }
    cout<<aa;
    return 0;
}

by zgr0712 @ 2024-06-27 20:26:30

QWQ


by lzm0107 @ 2024-06-27 20:32:45

i < 9 and i < 10 @zgr0712


by Backint_Qf1 @ 2024-06-27 20:34:47

第6行循环,i<9,有十个数据,应改成i<10或i<=9


by wizard(偷开O2 @ 2024-06-27 20:35:00

@zgr0712 少输入了一个数啊


by zgr0712 @ 2024-06-27 20:42:54

谢谢dalaoQWQ


by zgr0712 @ 2024-06-27 20:45:26

@zgr0712


by yuzhang_chen @ 2024-07-04 10:43:34

https://img.picui.cn/free/2024/06/27/667d5e7777961.jpg


by liuruichen114514 @ 2024-07-18 19:24:31

http://noi.openjudge.cn/ch0106/01/


|