How to check if an integer is in a given range?

前端 未结 18 1370
遥遥无期
遥遥无期 2020-11-27 03:58

Hoping for something more elegant than

if (i>0 && i<100) 
18条回答
  •  温柔的废话
    2020-11-27 04:45

    Use this code :

    if (lowerBound <= val && val < upperBound)
    or
    if (lowerBound <= val && val <= upperBound)
    

提交回复
热议问题