Switch的流程图怎么画

时间: 2024-02-01 08:10:12 浏览: 153
Switch语句的流程图可以通过以下步骤来画出: 1. 确定Switch语句的表达式和各个case的常量表达式。 2. 在流程图中绘制一个判断节点,表示Switch语句的表达式。 3. 从判断节点出发,绘制多个分支,每个分支对应一个case。 4. 在每个分支中,绘制相应的语句块。 5. 在每个分支的末尾,绘制一个连接节点,表示跳出Switch语句。 6. 在Switch语句的末尾,绘制一个连接节点,表示结束Switch语句。 下面是一个示例的Switch语句的流程图: ```flow st=>start: 开始 op1=>operation: 输入表达式 cond1=>condition: 表达式是否等于常量表达式1? op2=>operation: 执行语句块1 op3=>operation: 跳出Switch语句 cond2=>condition: 表达式是否等于常量表达式2? op4=>operation: 执行语句块2 op5=>operation: 跳出Switch语句 cond3=>condition: 表达式是否等于常量表达式3? op6=>operation: 执行语句块3 op7=>operation: 跳出Switch语句 op8=>operation: 执行语句块n op9=>operation: 跳出Switch语句 e=>end: 结束 st->op1->cond1 cond1(yes)->op2->op3->e cond1(no)->cond2 cond2(yes)->op4->op5->e cond2(no)->cond3 cond3(yes)->op6->op7->e cond3(no)->op8->op9->e ```

相关推荐

void Show_Extend() { //cleardevice(); Date_IMAGE_Init(); Play = { 400,350,169,52, BLACK,"简单模式" }; Introduce = { 400, 404, 169, 52, BLACK, "困难模式" }; Upgrade_of_Combat = { 400, 456, 169, 52,BLACK, "炼狱模式" }; while(1) { // 贴图 & 绘制按键 DrawAlpha_Transparent(&img_tmp_Extend, 0, 0, &img_Extend); DrawAlpha_Transparent(&img_tmp_Extend, Play.x, Play.y, &img_Extend_Button); DrawAlpha_Transparent(&img_tmp_Extend, Introduce.x, Introduce.y, &img_Extend_Button); DrawAlpha_Transparent(&img_tmp_Extend, Upgrade_of_Combat.x, Upgrade_of_Combat.y, &img_Extend_Button); DrawAlpha_Transparent(&img_tmp_Extend, 100, 0, &Plane_Game); putimage(0, 0, &img_tmp_Extend); DrawImage_BUTTON(&Play); DrawImage_BUTTON(&Upgrade_of_Combat); DrawImage_BUTTON(&Introduce); FlushBatchDraw(); // 按键判断 if (MouseHit()) { MOUSEMSG msg = GetMouseMsg(); if (Switch_Buton(&Play, msg.x, msg.y)) Play.color = RGB(234, 54, 128); else Play.color = BLACK; if (Switch_Buton(&Upgrade_of_Combat, msg.x, msg.y)) Upgrade_of_Combat.color = RGB(234, 54, 128); else Upgrade_of_Combat.color = BLACK; if (Switch_Buton(&Introduce, msg.x, msg.y)) Introduce.color = RGB(234, 54, 128); else Introduce.color = BLACK; switch (msg.uMsg) { case WM_LBUTTONDOWN: if (Switch_Buton(&Play, msg.x, msg.y)) // 简单模式 { enemya_num = 12; v_enemyb = 3; v_enemyc = 5; BOSS_Damage = 5; BOSS_num = 12; goto next; } if (Switch_Buton(&Upgrade_of_Combat, msg.x, msg.y)) // 困难模式 { enemya_num = 15; v_enemyb = 6; v_enemyc = 8; BOSS_Damage = 8; BOSS_num = 15; goto next; } if (Switch_Buton(&Introduce, msg.x, msg.y)) // 炼狱模式 { enemya_num = 20; v_enemyb = 9; v_enemyc = 10; BOSS_Damage = 15; BOSS_num = 20; goto next; } } } } next: Init_Button(); f[0] = 0; cleardevice(); }请为上述程序画出流程图

/***************************************************** 湖南创乐博智能科技有限公司 name:Humiture Detection function:you can see the current value of humidity and temperature displayed on the I2C LCD1602. ******************************************************/ //include the libraries #include <dht.h> #include #include <Wire.h> LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 and 0x3F for a 16 chars and 2 line display dht DHT;//create a variable type of dht const int DHT11_PIN= A0;//Humiture sensor attach to pin7 void setup() { Serial.begin(9600);//initialize the serial lcd.init(); //initialize the lcd lcd.backlight(); //open the backlight } void loop() { //READ DATA //Serial.println("DHT11:"); D: int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor switch (chk) { case DHTLIB_OK: //Serial.println("OK!"); break; case DHTLIB_ERROR_CHECKSUM: //goto D; // Serial.print("Checksum error,\t"); break; case DHTLIB_ERROR_TIMEOUT: goto D; Serial.print("Time out error,\t"); break; default: // goto D; Serial.print("Unknown error,\t"); break; } // DISPLAY DATA lcd.setCursor(0, 0); lcd.print("Tem:"); Serial.print("Tem:"); lcd.print(DHT.temperature,1); //print the temperature on lcd Serial.print(DHT.temperature,1); lcd.print(char(223));//print the unit" ℃ " lcd.print("C"); Serial.println(" C"); lcd.setCursor(0, 1); lcd.print("Hum:"); Serial.print("Hum:"); lcd.print(DHT.humidity,1); //print the humidity on lcd Serial.print(DHT.humidity,1); lcd.print(" %"); Serial.println(" %"); delay(200); //wait a while } 根据上述代码画出流程图并且写出关键函数的理解使用并写出代码逻辑的文字表述

最新推荐

recommend-type

net学习笔记及其他代码应用

请画出遍历所有文件名(FileName)的流程图(请使用递归算法)。 答: void FindFile( Directory d ) { FileOrFolders = d.GetFileOrFolders(); foreach( FileOrFolder fof in FileOrFolders ) { if( fof is ...
recommend-type

基于Python的蓝桥杯竞赛平台的设计与实现

【作品名称】:基于Python的蓝桥杯竞赛平台的设计与实现 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目介绍】:基于Python的蓝桥杯竞赛平台的设计与实现
recommend-type

python实现基于深度学习TensorFlow框架的花朵识别项目源码.zip

python实现基于深度学习TensorFlow框架的花朵识别项目源码.zip
recommend-type

3-9.py

3-9
recommend-type

郊狼优化算法COA MATLAB源码, 应用案例为函数极值求解以及优化svm进行分类,代码注释详细,可结合自身需求进行应用

郊狼优化算法COA MATLAB源码, 应用案例为函数极值求解以及优化svm进行分类,代码注释详细,可结合自身需求进行应用
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

2. 通过python绘制y=e-xsin(2πx)图像

可以使用matplotlib库来绘制这个函数的图像。以下是一段示例代码: ```python import numpy as np import matplotlib.pyplot as plt def func(x): return np.exp(-x) * np.sin(2 * np.pi * x) x = np.linspace(0, 5, 500) y = func(x) plt.plot(x, y) plt.xlabel('x') plt.ylabel('y') plt.title('y = e^{-x} sin(2πx)') plt.show() ``` 运行这段
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。