条件分支结构,一般都是用switch-case结构:
输入:2
输出:this is 2
输入:3
输出:this is 3
输入:(其他数字)
输出:no output
缺点是:case后面只能是个常量,等于把条件结构给写死了
然后,需要条件判断是个变量的时候,用if-else if-else结构,能灵活点
例:
输入:2
输出:this is 2
输入:3
输出:this is 3
输入:(其他数字)
输出:no output
条件分支结构,一般都是用switch-case结构:
输入:2
输出:this is 2
输入:3
输出:this is 3
输入:(其他数字)
输出:no output
缺点是:case后面只能是个常量,等于把条件结构给写死了
然后,需要条件判断是个变量的时候,用if-else if-else结构,能灵活点
例:
输入:2
输出:this is 2
输入:3
输出:this is 3
输入:(其他数字)
输出:no output