为社么我的这个代码只得10分?

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

geyijin @ 2024-06-19 09:49:31

#include <iostream>
using namespace std;

long cnt;
int k;
int a[19];

int main() {
    for (int i = 1; i <= 10; ++i) {
        cin >> a[i];

    }
    cin >> k;
    k = k + 30;
    for (int i = 1; i <= 10; ++i) {
        if (a[i] >= k) {
            cnt++;
        }
    }
    cout << cnt;

    return 0;
}

by huangshuchang @ 2024-06-19 10:35:49

#include<bits/stdc++.h>
using namespace std;
int a[15]; 
int main(){
    int t,c=0;
    for(int i=0;i<10;i++) cin>>a[i];
    cin>>t;
    for(int i=0;i<10;i++){
        if(t+30>=a[i]){
            c++;
        }
    }
    cout<<c;
    return 0;
}

@geyijin


by huangshuchang @ 2024-06-19 10:39:14

@geyijin

a[i] >= k要改成k>= a[i]


by huangshuchang @ 2024-06-19 10:40:50

@geyijin 求关注


by geyijin @ 2024-06-22 09:21:12

@huangshuchang 好


by geyijin @ 2024-06-22 09:25:06

@huangshuchang thanks


|