新手求助,莫名累加器无法工作

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

CREED @ 2017-09-19 21:16:53

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

by I_FUCK_CM @ 2017-09-19 21:20:52

i等于多少啊


by Captain_Paul @ 2017-09-19 21:21:09

循环中i的初值?


by 落寞音箫 @ 2017-09-19 21:23:38

是a【i】>n,以及要将i初始化为1


by KillerXu @ 2017-09-19 21:31:21

i是随机值多尴尬


by CREED @ 2017-09-19 21:39:13

哦,懂了。谢谢各位大佬


|