哈工大-5选择控制结构方案.ppt

5.8用于多路选择的switch语句 The structure is similar to multiple selection (flowchart) switch (expression) { case value1 : statement1; break; case value2 : statement2; break; …… default : statementX; break; } Don’t forget the braces !! Don’t forget the colons !! Don’t forget the blank !! Important Rule ! switch (expression) { case value1 : statement1; break; case value2 : statement2; break; …… default : statementX; break; } Must be int or char! 5.8用于多路选择的switch语句 注意! Example: switch (month) { case 1: printf(January\n); break; case 2: pri

文档评论(0)

1亿VIP精品文档

相关文档