[英]Compilation errors on Codeforces, using MS visual studio 2019 C++
#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 '}'
or
in C++ is an "alternative token". or
在 C++ 中是“替代令牌”。
Your version of Visual Studio doesn't support these alternative tokens in your compilation mode .您的 Visual Studio 版本在您的编译模式中不支持这些替代标记。
Technically, that is in violation of the C++ standard.从技术上讲,这违反了 C++ 标准。
However, it would anyway be more conventional to write ||
但是,无论如何写||
会更传统。 , so just do that. ,所以就这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.