#include <iostream>
using namespace std;
int main() { //Main Function
int w;
cout << "enter the weight of the watermelon: ";
cin >> w;
if (w <= 1 or w >= 100) {
cout << "error";
}
else {
if (w % 2 == 0) {
cout << "YES";
}
else {
cout << "NO";
}
}
return 0;编译错误:
syntax error: missing ')' before identifier 'or'
error C2065: 'or': undeclared identifier
error C2146: syntax error: missing ';' before identifier 'w'
error C2059: syntax error: ')'
error C2059: syntax error: ';'
error C2059: syntax error: 'else'
error C2143: syntax error: missing ';' before '{'
error C2447: '{': missing function header (old-style formal list?)
error C2059: syntax error: 'return'
error C2059: syntax error: '}'
error C2143: syntax error: missing ';' before '}'发布于 2020-05-24 01:21:52
C++中的or是一个“替代令牌”。
您的Visual Studio doesn't support these alternative tokens in your compilation mode版本。
从技术上讲,这违反了C++标准。
然而,不管怎样,编写||会更传统,所以就这么做吧。
https://stackoverflow.com/questions/61975753
复制相似问题