gpt4 book ai didi

c - 带有 if 语句的 bool 表达式中的问题

转载 作者:太空宇宙 更新时间:2023-11-04 06:07:39 25 4
gpt4 key购买 nike

我需要一些确认。我总是得到正确的 o/p 但有人告诉我下面的表达式不起作用

提前致谢。

#define a 11

#define b 12

#define c 13
// I want if array[i] has values of any of these then do something
if( array[i] == (a) ||(b) ||( c))
// some function
else
printf("no match");

最佳答案

 if (array[i] ==  a || array[i] == b || array[i] == c){
...
}

有时我确实希望你可以说 if (array[i] == [a, b, c]) 或类似的东西。

关于c - 带有 if 语句的 bool 表达式中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6778365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com