Larger than and less than in C switch statement

后端 未结 7 839
闹比i
闹比i 2020-12-29 04:57

I\'m trying to write a code that has a lot of comparison

Write a program in “QUANT.C” which “quantifies” numbers. Read an integer “x” and test it, pro

7条回答
  •  一向
    一向 (楼主)
    2020-12-29 05:34

    Use:

    switch (option(a)) {
        case (0): ...
        case (1): ...
        case (2): ...
        case (n): ...
    

    Where the option() function is simply a function with if else.

    It lets you keep the clean look of a switch and the logic part is elsewhere.

提交回复
热议问题