首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MS visual studio 2019 C++时Codeforces上的编译错误

使用MS visual studio 2019 C++时Codeforces上的编译错误
EN

Stack Overflow用户
提问于 2020-05-24 01:12:31
回答 1查看 61关注 0票数 0
代码语言:javascript
复制
#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;

编译错误:

代码语言:javascript
复制
 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 '}'
EN

回答 1

Stack Overflow用户

发布于 2020-05-24 01:21:52

C++中的or是一个“替代令牌”。

您的Visual Studio doesn't support these alternative tokens in your compilation mode版本。

从技术上讲,这违反了C++标准。

然而,不管怎样,编写||会更传统,所以就这么做吧。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61975753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档