当前位置:网站首页>判断语句_switch与case
判断语句_switch与case
2022-08-05 04:52:00 【乖女子@@@】
[1]语法
switch后面跟随的值可以是值也可为表达式,但是case后面仅能为 值!
switch (值/表达式){
case value1:
statements1 // 当表达式/值的结果等于 value1 时,则执行该代码
break;
case value2:
statements2 // 当表达式/值的结果等于 value2 时,则执行该代码
break;
......
case valueN:
statementsN // 当表达式/值的结果等于 valueN 时,则执行该代码
break;
default :
statements // 如果没有与表达式/值相同的值,则执行该代码
}
[2]比较过程
switch 语句根据表达式的值,依次与 case 子句中的值进行比较:
- 如果两者相等,则执行其后的语句段,当遇到 break 关键字时则跳出整个 switch 语句。
- 如果不相等,则继续匹配下一个 case。
- switch 语句包含一个可选的 default 关键字,如果在前面的 case 中没有找到相等的条件,则执行 default 后面的语句段
- 比较过程为
全等!
边栏推荐
- mutillidae download and installation
- [极客大挑战 2019]FinalSQL
- C语言-大白话理解原码,反码和补码
- 七夕节赚徽章拉
- 【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】
- Bytebuffer put flip compact clear method demonstration
- Excel画图
- [MRCTF2020] Ezpop (detailed)
- About the installation of sklearn library
- [Nine Lectures on Backpacks - 01 Backpack Problems]
猜你喜欢
How to identify false evidence and evidence?

【转】什么是etcd
![【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】](/img/b5/716627b370e489ccf320a86540f7ba.png)
【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】

Day019 Method overriding and introduction of related classes

Excel画图

mutillidae download and installation

App rapid development and construction experience: the importance of small programs + custom plug-ins

bytebuffer 内部结构

WPF中DataContext作用

Dephi逆向工具Dede导出函数名MAP导入到IDA中
随机推荐
[BSidesCF 2019]Kookie
Redis - 13、开发规范
为什么刚考完PMP,就开始准备软考了?
Detailed explanation of each module of ansible
[8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
Flutter learning three-Flutter basic structure and principle
【无标题】
[SWPU2019]Web1
bytebuffer internal structure
Day14 jenkins deployment
MySQL中控制导出文件后变为了\N有什么解决方案吗?
程序开发的一些常规套路(一)
大学物理---质点运动学
dedecms报错The each() function is deprecated
University Physics---Particle Kinematics
机器学习概述
Flutter学习4-基本UI组件
ESP32 485光照度
什么是ASEMI光伏二极管,光伏二极管的作用