2014-10-02 257 views

回答

1

将其更改为

if (test1 > 0 && test1 < 100) (1-99 are = true) 

- >它需要一个布尔结果。

0

呸,我不得不写TEST1两次。也弄错了操作员。

if (test1 >= 0 && test1 <= 100) // I get the error here. 
    { 
     cout << "This score is good." << endl; 
    } 
    else 
    { 
     cout << endl << "ERROR: " << test1 << " is not a valid test score."; 

     return 1; 
    } 
0

有两个缺陷。第一个导致编译器错误的是条件

if (test1 < 0 || > 100) // I get the error here. 

语法上写错了。应该有

if (test1 < 0 || test > 100) 

第二个缺陷,它会好得多,如果测试具有无符号整型。在这种情况下,您可以简化条件

if (test > 100) 
{ 
    cout << "This score is good." << endl; 
} 
else 
{ 
    cout << endl << "ERROR: " << test1 << " is not a valid test score."; 

    return 1; 
} 

您是否确定不是指以下内容?

if (test <= 100) 
{ 
    cout << "This score is good." << endl; 
} 
else 
{ 
    cout << endl << "ERROR: " << test1 << " is not a valid test score."; 

    return 1; 
} 
相关问题