当前位置: 首页 > news >正文

孝感英文网站建设注册餐饮公司需要什么条件

孝感英文网站建设,注册餐饮公司需要什么条件,服装网站页面设计,seo网络优化推广【Rust】003-基础语法#xff1a;流程控制 文章目录 【Rust】003-基础语法#xff1a;流程控制一、概述二、if 表达式1、语法格式2、多个3、获取表达式的值 三、循环1、loop#xff1a;无限循环#xff0c;可跳出无限循环跳出循环返回值 2、while#xff1a;条件循环…【Rust】003-基础语法流程控制 文章目录 【Rust】003-基础语法流程控制一、概述二、if 表达式1、语法格式2、多个3、获取表达式的值 三、循环1、loop无限循环可跳出无限循环跳出循环返回值 2、while条件循环可跳出3、for常用于访问集合访问集合while 示例访问集合for 示例对一个 range 进行循环 4、labels给循环加标签 一、概述 控制流是编程语言的一个重要概念。程序员通过控制流可以控制哪些代码要执行。在Rust中最常见的两种控制流结构是if表达式和循环。 二、if 表达式 1、语法格式 这里的 condition 必须是 bool 类型 if condition {// code to execute if the condition is true } else {// code to execute if the condition is false }2、多个 if condition1 {// code to execute if condition1 is true } else if condition2 {// code to execute if condition1 is false and condition2 is true } else {// code to execute if both conditions are false }3、获取表达式的值 正如这一小节的标题所说if其实是一个表达式具有返回值。 需要注意的是if分支和else分支的返回值必须是同一类型。 fn main() {let temperature 20;let weather if temperature 25 {hot} else {cool};println!(The weather today is {}., weather); }三、循环 Rust中提供了三种循环方式loopwhilefor。 1、loop无限循环可跳出 无限循环 loop关键字会创建一个无限循环 loop {// code to execute repeatedly }跳出循环 想要从循环中跳出需要配合break关键词使用下面的代码也展示了 continue 的用法 let mut counter 0;loop {counter 1;if counter 5 {continue;}println!(Hello, world!);if counter 5 {break;} }返回值 fn main() {let target 10;let mut sum 0;let mut counter 1;let result loop {sum counter;if sum target {break counter; // The value of counter will be returned from the loop as a result}counter 1;};println!(The first number whose sum of all previous numbers is greater than or equal to {} is {}., target, result); }2、while条件循环可跳出 while condition {// code to execute while the condition is true }3、for常用于访问集合 访问集合while 示例 fn main() {let numbers [1, 2, 3, 4, 5];let mut index 0;while index numbers.len() {println!(The value is: {}, numbers[index]);index 1;} }访问集合for 示例 fn main() {let numbers [1, 2, 3, 4, 5];for number in numbers {println!(The value is: {}, number);} }对一个 range 进行循环 这里的1..3表示[1,3]这个区间的整数。如果是左闭右开要写成1..3。 fn main() {for x in 1..3 {println!(x: {}, x);} }4、labels给循环加标签 三种循环都支持 当循环存在嵌套关系时break和continue只会对最内层的循环生效。但是有时候我们希望可以对外层的循环做break或者continue这时该怎么办幸运的是Rust 可以给循环加上标签从而break和continue都可以直接操作标签。 fn main() {let x 1;outer: loop {let mut y 1;inner: loop {if y 3 {y 1;continue inner; // Skips to the next iteration of the inner loop}println!(x: {}, y: {}, x, y);y 1;if y 5 {break outer; // Breaks out of the inner loop}}} }带返回值 fn main() {let x 1;let z outer: loop {let mut y 1;inner: loop {if y 3 {y 1;continue inner; // Skips to the next iteration of the inner loop}println!(x: {}, y: {}, x, y);y 1;if y 5 {break outer y; // Breaks out of the inner loop}}};println!(z: {}, z); }
http://www.w-s-a.com/news/471693/

相关文章:

  • 网站项目开发收费标准网站开发app开发主营业务
  • 怎么到国外网站去接模具订单做互联网建设企业网站
  • 深圳品牌网站建设公司排名洪雅网站建设
  • nodejs 做网站wordpress主题绕过激活码
  • 平湖模板网站建设公司网页美工培训
  • 顺德网站建设市场建设工程交易中心网站
  • 深圳企业网站怎么做浪琴手表网站建设图
  • 2018网站外链怎么做济南 网站设计公司
  • 承德百度网站建设郑州网站seo优化公司
  • 四川建站模板网站公司分类信息网站制作
  • 网站开发前后端有wordpress模板安装教程视频教程
  • 有网站想修改里面的内容怎么做怎么做黑彩黑彩网站
  • 什么专业会做网站网站建设续费合同
  • 网站开发的项目开发网站做直播功能需要注册吗
  • 网站开发新手什么软件好网站设计师和ui设计师
  • 太仓苏州网站建设软件开发网站建设
  • 一个虚拟主机做2个网站吗工信部怎么查网站备案
  • 本地网站做淘宝客制作app步骤
  • 关于企业网站建设网页布局怎么设计
  • 惠州市网站设计公司裴东莞嘘网站汉建设
  • 长葛网站建站电子商务网站是什么
  • 泉做网站的公司太原网站建设开发公司
  • wordpress菜单栏的函数调用迅速上排名网站优化
  • 网站深圳广西模板厂哪家价格低
  • 搜索网站显示网页无法访问最好的网站推广
  • 巴彦淖尔市百家姓网站建设搬瓦工暗转wordpress
  • 温州鹿城区企业网站搭建云虚拟机
  • 网站的开发方法php网站商城源码
  • 旅游找什么网站好维护公司网站建设
  • 长春市长春网站制作站优化杭州企业推广网站