大佬求解,0分

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

PWmk1 @ 2018-12-07 17:09:23

include<iostream>

using namespace std; const int MAXN=10; int main() { int a[MAXN]; int b,c; c=0; for(int i=1;i<=MAXN;i++) { cin>>a[i]; } cin>>b; for(int i=1;i<=MAXN;i++) { if(b+30>=a[i]) c++; } cout<<c; return 0; }


by PWmk1 @ 2018-12-07 17:09:56

// luogu-judger-enable-o2

include<iostream>

using namespace std; const int MAXN=10; int main() { int a[MAXN]; int b,c; c=0; for(int i=1;i<=MAXN;i++) { cin>>a[i]; } cin>>b; for(int i=1;i<=MAXN;i++) { if(b+30>=a[i]) c++; } cout<<c; return 0; }


by HAO233 @ 2018-12-07 17:17:12

希望更丰富的展现?使用Markdown


by PWmk1 @ 2018-12-07 17:25:28

printf("#include<iostream> using namespace std; const int MAXN=10; int main() { int a[MAXN]; int b,c; c=0; for(int i=1;i<=MAXN;i++) { cin>>a[i]; } cin>>b; for(int i=1;i<=MAXN;i++) { if(b+30>=a[i]) c++; } cout<<c; return 0; }")


by PWmk1 @ 2018-12-07 17:26:46

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

by PWmk1 @ 2018-12-07 17:27:25

终于正常了


by 小元勋 @ 2018-12-07 17:27:26

include <bits/stdc++.h>

using namespace std; int a[15],b,ans=0; int main() { for(int i=1;i<=10;i++) { scanf("%d ",&a[i]); } scanf("%d",&b); int x=b+30; for(int i=1;i<=10;i++) { if(x>=a[i]) ans++; } printf("%d",ans); return 0; }


by 小元勋 @ 2018-12-07 17:27:41

你可以参考一下我的


by 赫敏·东方延绪 @ 2018-12-07 17:42:37

数组越界

数组a[10]的范围是 a[0]~a[9]

const int MAXN=10;

换成

const int MAXN=11;

by Priori_Incantatem @ 2018-12-07 18:30:49

我也觉得是


by PWmk1 @ 2018-12-13 10:37:21

谢谢


| 下一页