我想在c ++中做这样的事情
If x is equal to either a or b or c
and y is equal to either d or e or f
and z is equal to either g or h or i, it would turn true and execute the code
Run Code Online (Sandbox Code Playgroud)
我有点迷失了
if(x==a||x==b||x==c && y==d||y==e||y==f && z==g||z==h||z==i){
// Do x
}
Run Code Online (Sandbox Code Playgroud)
只需使用,&&并||使用括号使分组清晰.
if ((x == 'a' || x == 'b' || x == 'c')
&& (y == 'd' || y == 'e' || y == 'f')
&& (z == 'g' || z == 'h' || z == 'i')) {
// execute code
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
143 次 |
| 最近记录: |