编译失败

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

MuYuMC @ 2024-07-10 15:10:45

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int A[10000];
int main() {
    int a, i, cnt = 0;
    for (i = 1; i <= 10; i++)
    {
        cin >> A[i];
    }
    cin >> a;
    for (i = 1; i <= 10; i++)
    {
        if (A[i] <= a)
        {
            cnt++;
        }
        else {
            if (A[i] <= a + 30)
            {
                cnt++;
            }
        }
    }
    cout << cnt;
    return O;
}

by zxh923 @ 2024-07-10 15:11:47

@MuYuMC return 0 而不是 O


by Tiskan_H @ 2024-07-10 15:12:22

return 0而不是O!@ MuYuMC


by MuYuMC @ 2024-07-10 15:12:28

@zxh923 啊,眼瞎了,qwq谢谢


by Xingyi_2014 @ 2024-07-28 11:47:29

较简单的代码:


by Xingyi_2014 @ 2024-07-28 11:47:49

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

|