为啥错了啊,求指教

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

XuanH @ 2020-11-07 23:00:53

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

by Tianxn @ 2020-11-08 16:17:03

#include <iostream>
using namespace std;
int a[12];
int main() {
    for (int i = 1; i <= 11; cin >> a[i++]);
    for (int i = 1; i <= 10; ++i)
        if (a[i] <= a[11] + 30) a[0]++;
    cout << a[0] << endl; 
    return 0;
} 

by CQWDX @ 2020-12-12 21:05:08

#include <iostream>
using namespace std;
int main(){
    int long,a[10],s=0;
    for(int i=0;i<10;i++){
        cin >> a[i];
    }
    cin >> long;
    for(int i=0;i<10;i++){
        if(a[i]+30<=long){
            s++;
        }
    }
    cout << s;
    return 0;
}

by 青莲梵音 @ 2021-03-07 20:03:00

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int appleh[10], benchh, taoh, bentaoh, i;
    benchh = 30;   
    for (i=0; i<10; i++)   
    {
        scanf("%d", &appleh[i]);
    }
    scanf("%d", &taoh);    
    bentaoh = benchh + taoh;   
    int n = 0;
    for (i=0; i<10; i++)  
    {
        if(appleh[i] <= bentaoh)
        {
            n++;   
        }
    }
    printf("%d\n", n);
    return 0;
}

by LanD_twh @ 2021-03-23 13:18:25

#include<bits/stdc++.h>
using namespace std;
int MAXN=10000;
int main()
{
    int a[MAXN],tall,get=0,total;
    for(int i=1;i<=10;i++)
    {
        cin >> a[i];
    }
    cin >> tall;
    total = tall+30;
    for(int i=1;i<=10;i++)
    {
        if(a[i]<=total)
        {
            get++;
        }
    }
    cout << get;
    return 0;
}

by 麤饙鱻淼龘 @ 2021-04-26 22:08:22

@XuanH 是这样的

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

by After_light @ 2021-10-07 20:01:21

#include<iostream>
using namespace std;
int main()
{
    int a[100],m;
    for(int i=1;i<=10;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    m=m+30;
    int sum=0;
    for(int i=1;i<=10;i++)
    {
        if(m>=a[i])
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}

by Li_Dao_Yuan @ 2021-12-05 10:12:23

C++代码如下

#include<cstdio>
using namespace std;
int main(){
    int d[11],a=0,t;
    for(int i=1;i<=10;i++){
        scanf("%d",&d[i]);  
    }
    scanf("%d",&t);
    t=t+30;
    for(int i=1;i<=10;i++){
        if(d[i]<=t) a++;
    }
    printf("%d",a);
    return 0;
}

|