Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.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++_Arrays_Runtime Error_Output - Fatal编程技术网

C++ 并行阵列的输出错误

C++ 并行阵列的输出错误,c++,arrays,runtime-error,output,C++,Arrays,Runtime Error,Output,您有两个地方可以打印某些内容: const string GRADE_LETTERS[] = { "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F" }; const double GRADE_BOUNDS[] = { 92.0, 90.0, 87.0, 82.0, 80.0, 77.0, 72.0, 70.0, 67.0, 62.0, 60.0, 0.0 }; const int GRADE_COUNT =

您有两个地方可以打印某些内容:

const string GRADE_LETTERS[] = { "A", "A-", "B+",  "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F" };

const double GRADE_BOUNDS[] =  { 92.0, 90.0, 87.0, 82.0, 80.0, 77.0, 72.0, 70.0, 67.0, 62.0, 60.0, 0.0 };
const int GRADE_COUNT = sizeof( GRADE_BOUNDS ) / sizeof( GRADE_BOUNDS[0] );
if(studentGrades[i]>=年级界限[0])/>92.0

else if(studentGrades[i]如果你有一个分数,那么当你在前两个if语句中找到下一个学生时,你忘记了继续下一个学生,那么你会得到一个分段错误:

    if(studentGrades[i]<GRADE_BOUNDS[j]&&studentGrades[i]>=GRADE_BOUNDS[j+1])
if(studentGrades[i]>=GRADE\u界限[0])
{

coutWelcome to StackOverflow!感谢您将精力投入到发布代码上下文和精确构建您的问题中-这真的很有帮助。愉快的编码!我还没有学会continue关键字,我猜如果我使用continue,它将完全跳过嵌套的for循环,并再次迭代第一个for循环?Noob问题我知道>>它将运行递增计数器,如果满足条件,它将再次进入循环(结束当前迭代).分段错误,不确定这意味着什么,但我不相信我正在访问此代码段中的任何地方的-1索引。我同意访问j+1最终会导致溢出,但前提是分数不在0.0-100.0的范围内,对吗?唯一可能导致溢出的方法是在搜索0.0-100.0时输入是未找到。它将尝试搜索等级界限[13]这是不存在的。我想我不确定你想说什么你是对的,我看到了一个j-1而不是j+1,事实上,你改变了代码,你有j-1…我有j-1,因为在我发布我的问题之前,我想尝试一些其他的选择,这样我就不会看起来像一个需要抱怨的人或任何东西。我试着减少j,设置j=GRADE_COUNT和do j>0。但是,唉,它不起作用。我意识到我有j-1,这是编辑的一部分,非常感谢你,这很有意义。它检查两个条件,如果然后,它将迭代嵌套的for循环,它不会检查>=92.0的上限,但最终会检查0=非常好!我赞成这种方法你重新措辞了答案以帮助自己解释。祝你作业顺利!不要担心自己是初学者——我们都去过一次。继续努力。
    if(studentGrades[i]>=GRADE_BOUNDS[0]) // > 92.0
    else if(studentGrades[i]<GRADE_BOUNDS[10]) // < 60.0
    if(studentGrades[i]<GRADE_BOUNDS[j]&&studentGrades[i]>=GRADE_BOUNDS[j+1])
if(studentGrades[i]>=GRADE_BOUNDS[0])
{
    cout<<"Student "<<i<<" got "<<studentGrades[i]<<" which is a(n) "<<GRADE_LETTERS[0]<<endl;
    continue;
 }        
 else if(studentGrades[i]<GRADE_BOUNDS[10])
 {
    cout<<"Student "<<i<<" got "<<studentGrades[i]<<" which is a(n) "<<GRADE_LETTERS[11]<<endl;
    continue;
 }