c++14语言帮帮我吧!

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

Zjc20120331 @ 2021-12-26 14:03:32

代码有错吗?

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int pgg[10];
    int sg, pgs = 0;

    for (int i = 0; i < 10; i++)
    {
        cin >> pgg[i];
    }
    cin >> sg;

    for (int i = 0; 1 < 10; i++)
    {
        if ((sg+30) >= pgg[i])
        {
            pgs++;
            cout << pgg[i];//调试需要 
        }
    }

    cout << pgs;

    return 0;
}

运行出来一大堆数字


by BootsH @ 2021-12-26 14:05:07

调试没删


by Haber @ 2021-12-26 14:07:21

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int pgg[10];
    int sg, pgs = 0;

    for (int i = 0; i < 10; i++)
    {
        cin >> pgg[i];
    }
    cin >> sg;

    for (int i = 0; i < 10; i++)
    {
        if ((sg+30) >= pgg[i])
        {
            pgs++;
            //cout << pgg[i];调试需要 
        }
    }

    cout << pgs;

    return 0;
}

第16行i打成1了


by _Lionel @ 2021-12-26 14:18:42

主页两贴,危!


|