Determine if a number falls within a specified set of ranges

后端 未结 8 1552
耶瑟儿~
耶瑟儿~ 2021-02-02 13:45

I\'m looking for a fluent way of determining if a number falls within a specified set of ranges. My current code looks something like this:

int x = 500; // Could         


        
8条回答
  •  耶瑟儿~
    2021-02-02 14:02

    if you need to iterate over the value pairs at some point, I suggest you capture the maximum lower value and the minimum upper value as you do into variables and do:

    if ( x>max_lower && x 

提交回复
热议问题