我有这个代码:
#include <iostream>
using namespace std;
int main()
{ char c='6';
if(c == '+' || '-' || '*' || '^' || '/' || '%')
{
cout<<"good";
}
else {cout<<"bad";}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果char是'+'或' - '等,我想写"好",如果char是其他任何东西,我想写"坏".但是这段代码总是用任何字母写"好".
问题出在哪儿?谢谢.
c++ ×1