C++ 理由不正确 if(ch1='l'| |'l') cout
C++ 理由不正确 if(ch1='l'| |'l') cout,c++,C++,if (ch1 = 'l' || 'L') cout << left; else if (ch1 = 'r' || 'R') cout << right; else cout << "error" << endl; cout << setw(++aw) << setfill(char(a)) << s1 << endl;
if (ch1 = 'l' || 'L')
cout << left;
else if (ch1 = 'r' || 'R')
cout << right;
else
cout << "error" << endl;
cout << setw(++aw) << setfill(char(a)) << s1 << endl;
if (ch2 = 'l' || 'L')
cout << left;
else if (ch2 = 'r' || 'R')
cout << right;
else
cout << "error" << endl;
cout << setw(++bw) << setfill(char(b)) << s2 << endl;
if (ch3 = 'l' || 'L')
cout << left;
else if (ch3 = 'r' || 'R')
cout << right;
else
cout << "error" << endl;
cout << setw(++cw) << setfill(char(c)) << s3 << endl;
return 0;
}
if(ch1=='l'| | ch1=='l')
ch1=左;
else if(ch1=='r'| | ch1=='r')
ch1=右;
其他的
当你写作时,例如
if (ch1 == 'l' || ch1 == 'L')
ch1 = left;
else if(ch1 == 'r' || ch1 == 'R')
ch1 = right;
else
cout << "error" << endl;
这永远是真的,因为你实际上是在说
if (ch1 = 'l' || 'L')
或
相反,正确的编写方法是使用double=
if 'L' is not equal to zero (which always is !=0)
或
<代码>然后不是C++关键字……你需要学习一些基本的C++,包括文字值,比如字符文字>代码> L '/COD>。另外,如何在AND或or链中使用多个条件。我们可以看看ch1
、left
和right
的声明吗?
if 'L' is not equal to zero (which always is !=0)
if ( ch1 == 'l' || ch1 == 'L')
if ( toupper( ch1 ) == 'L' )