#2154. C++-编译-lvalue required as left(或right) operand of assignment
C++-编译-lvalue required as left(或right) operand of assignment
Background
Description
不正确的左值,左值不能为表达式,最常见的是以下情况:
1.条件语句的==写成=,如:
int a=3;
if (a%2=1) cout<<"true"; //这里的条件运算符==错写成赋值运算符=
if (a%2==1) cout<<"true"; //改正后
2.试图给一个表达式赋值,如:
int a=3;
a*2=3; //赋值语句的左边不能是表达式
3.试图给一个常数赋值,如:
int a=3;
4=a; //不能给4赋值
Format
Input
Output
Samples
Limitation
1s, 1024KiB for each test case.