How to quickly tell which range the number is in?

The
requirement is as follows:
calculate a grade based on an interval

Diamond Shop

< table > < thead > < tr > < th align= "center" > drill into the store < / th > < th align= "center" > Erjing Store < / th > < th align= "center" > three Diamond shops < / th > < th align= "center" > four Diamond Store < / th > < th align= "center" > five Diamond Shop < / th > < / tr > < / thead > < tbody > < tr > < td align= "center" > 1-50 < / td > < td align= "center" > 51-100 < / td > < td align= "center" > 101500 < / td > < td align= "center" > 591-1000 < / td > < td align= "center" > 1001-2000 < / td > < / tr > < / tbody > < / table >

Crown

< table > < thead > < tr > < th align= "center" > Top Store < / th > < th align= "center" > second Crown Store < / th > < th align= "center" > Triple Crown Store < / th > < th align= "center" > four Crown Store < / th > < th align= "center" > five Crown Store < / th > < / tr > < / thead > < tbody > < tr > < td align= "center" > 2001-4000 < / td > < td align= "center" > 4001-6000 < / td > < td align= "center" > 6001-8000 < / td > < td align= "center" > 8001-10000 < / td > < td align= "center" > 10001-12000 < / td > < / tr > < / tbody > < / table >
now each has a number such as: 80 how do I know which paragraph he is? of course, you can if.else . Consider the simplest solution here!
Php
Mar.30,2021

can be realized with if.else , and it can also be realized with switch . Here is a code of switch , which is a bit coquettish and should not be easily imitated (escape

).
  

if you want to be faster, you can search on the balanced binary tree. For java, you can put it on TreeMap, and search through floorEntry ceilEntry .

Menu