Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我不断地得到;围绕变量';法官';腐败了。”;_C++_Visual C++_C++builder - Fatal编程技术网

C++ 我不断地得到;围绕变量';法官';腐败了。”;

C++ 我不断地得到;围绕变量';法官';腐败了。”;,c++,visual-c++,c++builder,C++,Visual C++,C++builder,我似乎无法让它正常工作,我不断得到“变量'judge'周围的堆栈已损坏”。我哪里出错了?它似乎运行正常,但在结束时,我在关闭后得到错误,我的lowNum值似乎无法正确处理 #include <iostream> using namespace std; const int SIZE = 5; double getJudgeData(int judge); double findLowest(double num[SIZE]); double findHighest(double

我似乎无法让它正常工作,我不断得到“变量'judge'周围的堆栈已损坏”。我哪里出错了?它似乎运行正常,但在结束时,我在关闭后得到错误,我的lowNum值似乎无法正确处理

#include <iostream>
using namespace std;

const int SIZE = 5;

double getJudgeData(int judge);
double findLowest(double num[SIZE]);
double findHighest(double num[SIZE]);

int main()
{
    double 
        judge[SIZE],
        highNum,
        lowNum;


    for(int num = 1; num <= SIZE; num++)
    {
        judge[num] = getJudgeData(num);
        highNum = findHighest(judge);
        lowNum = findLowest(judge);
    }

    cout << highNum << endl;
    cout << lowNum << endl;

    system ("pause");
    return 0;
}

double getJudgeData(int judge)
{
    double score;

    cout << "What is the score given by judge " << judge << "?" << endl;
    cin >> score;

    while(score < 0 || score > 10) 
    {
        cout << "Please enter a score between 0 and 10.\n\n";

        cout << "What is the score given by judge " << judge << "?" << endl;
        cin >> score;
    }

    return score;

}
double findHighest(double num[SIZE])
{
    double high = 0;

    for(int count=0;count<SIZE;count++)
    {
        if(num[count]>high)
        high=num[count];
    }

    return high;
}

double findLowest(double num[SIZE])
{
    double low = 10;

    for(int count=0;count<SIZE;count++)
    {
        if(num[count]<low)
        low=num[count];
    }

    return low;
}
#包括
使用名称空间std;
常数int SIZE=5;
双重判断数据(内部判断);
双findLowest(双数值[大小]);
双findHighest(双数值[大小]);
int main()
{
双重的
判断[大小],
海纳姆,
lowNum;

对于(int num=1;numC++使用了从0到n-1的数组。您的代码使用的是从1到n的数组,因此您“运行”了数组判断的末尾(并损坏了它周围的变量)


建议您关闭该问题,因为它只是一个输入错误。

数组[n]
的索引从0到n-1…您的
判断[num]= 由于数组条件“代码> > num而被破坏,编译器必须给出关于问题所在的非常高质量的信息,并且所有C++程序员都应该非常警惕数组的边界,当然我是新来的,我该怎么做?