10分 求指出错误

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

daydream1ng @ 2024-11-01 17:15:11


#include <bits/stdc++.h>
using namespace std;
int a[10];
int main()

{
        int max, sum = 0; cin >> max;
    for (int i = 0; i <= 9; i++){
        cin >> a[i];
        if (max + 30 >= a[i]){
            sum++;
        }

    }
    cout << sum;

}

by XYY62012 @ 2024-11-01 17:28:04

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[11],n,s=0;
    for(int i=1;i<=10;i=i+1)
        cin>>a[i];
    cin>>n;
    for(int i=1;i<=10;i=i+1){
        int y=30+n;
        if(y>=a[i]) s++;
    }
    cout<<s;
}

by kn01 @ 2024-11-01 17:28:18

@daydream1ng 先输入a[i],在输入b


by XYY62012 @ 2024-11-01 17:29:40

输入输反了


by daydream1ng @ 2024-11-01 17:46:57

@XYY62012 多谢!


by daydream1ng @ 2024-11-01 17:47:26

@kn01 谢谢!


|