-1

好的,我知道这比您想要的要多,但我确实无法在以下代码中找到问题

#include <iostream>
using namespace std ;

int main(void)
{
   int score1, score2;

   PrintInfo() ;

   score1 = GetScore(); //  Call function GetScore, to obtain a value for score1.

   if (RangeError()) ;  //  IF score1 is out of range, print an error message.
   {
       cout << "Sorry you entered an invalid score." << endl ;
   }
   else  // THIS IS LINE 46, THIS IS THE ELSE IT IS TALKING ABOUT
   {
       score2 = Getscore ; // Call GetScore a second time, to obtain a value for score2.

       if (RangeError ()); // IF score2 is out of range, print an error message.
       {
           cout << "Sorry you entered an invalid score." << endl ;
       }
       else  // ELSE, using a call to function maximum within a cout
       {     // statement, print the maximum score.
           cout << maximum() << endl ;
       }
   }

    return 0;
}

那里有很多,我知道,但主要问题似乎在我的第二个问题上。无论出于何种原因,我不断收到以下错误:

lab05a.cpp:46: 错误:在 'else' 之前需要 `}'

lab05a.cpp:在全球范围内:

lab05a.cpp:46: 错误: 'else' 之前的预期 unqualified-id

我知道这与括号有关,但我找不到任何问题!另外:对于缺少行号,我深表歉意,我们没有使用允许它们的编辑器。我本可以添加它们,但是为了简洁起见,我删除了很多不相关的文本,并且添加它们不会为错误提供正确的行号。因此,我将显示第 46 行的位置。我删除了大部分声明,因为问题似乎并不在于其中。请帮助我,这是我第一次遇到无法靠自己解决的问题。

4

1 回答 1

2
if (RangeError()) ;
{

应该

if (RangeError())
{
于 2012-10-22T01:32:49.877 回答