What is a good switch statement alternative?

后端 未结 4 837
时光取名叫无心
时光取名叫无心 2021-01-28 16:48

I have a string array containing strings of 3 letters each. Every 3 letters (every element) corresponds to a unique letter. I need to create a char array from the string array.<

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-28 17:47

    what language are you using?

    you could set up a look-up table using an array like so:

    lookuptable = { {'a','abc'},{'b','abd'} ....}

    then you just look up the corresponding value in the array.

    if your language supports dictionaries, it'll be even easier.

提交回复
热议问题