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

广州市人民政府网站英文seo兼职

广州市人民政府网站,英文seo兼职,成都推广公司联系电话,百度优化只做移动网站没有pc站流程控制 文章目录 流程控制一、if 语句1.if 嵌套语句 二、switch 语句三、for 循环四、string 程序的流程控制结构一具有三种:顺序结构,选择结构,循环结构 顺序结构:从上到下,逐行执行。默认的逻辑 选择结构&#xf…

流程控制


文章目录

  • 流程控制
  • 一、if 语句
    • 1.if 嵌套语句
  • 二、switch 语句
  • 三、for 循环
  • 四、string


在这里插入图片描述


程序的流程控制结构一具有三种:顺序结构,选择结构,循环结构

在这里插入图片描述

  • 顺序结构:从上到下,逐行执行。默认的逻辑

  • 选择结构:条件满足某些代码才会执行

    • if

    • switch

    • select ,后面 channel 再讲

  • 循环结构:条件满足某些代码会被反复执行0-N次

    • for

一、if 语句

条件语句需要开发者通过指定一个或多个条件,并通过测试条件是否为 true 来决定是否执行指定语句,并在条件为false的情况在执行另外的语句。

下图展示了程序语言中条件语句的结构:
在这里插入图片描述

package mainimport "fmt"func main() {// 分数var score int = 66if score >= 90 && score <= 100 {fmt.Println("优秀")} else if score >= 80 && score < 90 {fmt.Println("良好")} else if score >= 60 && score < 80 {fmt.Println("及格")} else {fmt.Println("不及格")}}

输出
在这里插入图片描述

1.if 嵌套语句

if 布尔表社式 1 {/* 在布尔表达式 1 为 true 3:执行 */if 布尔表达式 2 {/* 在布尔表达式 2 true 时执行 */}
}
package mainimport "fmt"func main() {var one, two int// 初始密码var pwd int = 12345678// 接收用户输入密码fmt.Print("请输入密码:")fmt.Scan(&one)// 功能:验证密码是否正确if one == pwd {fmt.Print("请再次输入密码:")fmt.Scan(&two)if two == pwd {fmt.Println("登录成功")} else {fmt.Println("第二次输入密码错误,登录失败,请重新输入密码……")}} else {fmt.Println("输入密码错误,登录失败,请重新输入密码……")}}

输出
在这里插入图片描述

二、switch 语句

switch语句用于基于不同条件执行不同动作,每一个case分支都是唯一的,从上至下逐一测试,直到匹配为止。

switch var1 { case test1:...case test2:...		defauIt:...
}

switch语句执行的过程从上至下,直到找到匹配项,匹配项后面也不需要再加 break.。switch默认情况下 case 最后自带 break 语句

package mainimport "fmt"func main() {var score string = "D"// 匹配switch score {case "A":fmt.Println("等级为A,成绩在90~100范围内")case "B":fmt.Println("等级为B,成绩在80~90范围内")case "C":fmt.Println("等级为C,成绩在60~79范围内")default:fmt.Println("等级为D,成绩在0~59范围内")}// switch 默认条件 bool = trueswitch {case false:fmt.Println("false")case true:fmt.Println("true")default:fmt.Println("其他")}
}

输出
在这里插入图片描述

fallthrough 贯穿,直通

switch默认情况下匹配成功后就不会执行其他case,如果我们需要执行后面的case,可以使用 fallthrough 穿透case使用 fallthrough 会强制执行后面的 case 语句,fallthrough不会判断下条case的表达结果是否为true.

package mainimport "fmt"func main() {a := false// switch 默认条件 bool = trueswitch a {case false:fmt.Println("false")fallthrough // case 穿透,不管下一个条件是否满足,都会执行case true:fmt.Println("true")default:fmt.Println("其他")}
}

输出
在这里插入图片描述

package mainimport "fmt"func main() {a := false// switch 默认条件 bool = trueswitch a {case false:fmt.Println("false")fallthrough // case 穿透,不管下一个条件是否满足,都会执行case true:if a == false {break // 终止 case 穿透}fmt.Println("true")default:fmt.Println("其他")}
}

输出
在这里插入图片描述

三、for 循环

在不少实际问题中有许多具有规律性的重复操作,因此在程序中就需要重复执行某些语句。for 循环是一个循环控制结构,可以执行指定次数的循环。

package mainimport "fmt"func main() {// for 条件的起始值;循环条件;控制变量自增或自减// for ;循环条件;// for {} 无限循环i := 1for {fmt.Println(i)i++}sum := 0// for 给控制变量赋值初值,循环条件给控制变量增量或减量\// 计算 1 到 10 的数字之和for i := 1; i <= 10; i++ {// 循环体sum += i}fmt.Println(sum)
}

栗子:输出一个10*10的方阵

package mainimport "fmt"func main() {// i 控制行, j 控制列 for i := 0; i < 10; i++ {for j := 0; j < 10; j++ {fmt.Print("* ")}fmt.Println()}}

输出
在这里插入图片描述
栗子:九九乘法表

package mainimport "fmt"func main() {// i 控制行, j 控制列for i := 1; i < 10; i++ {for j := 1; j <= i; j++ {fmt.Printf("%d*%d=%d \t", j, i, j*i)}fmt.Println()}}

输出
在这里插入图片描述

break 结束当前整个循环

package mainimport "fmt"func main() {for i := 1; i <= 6; i++ {if i == 4 {break}fmt.Println(i)}}

continue 结束本次循环

package mainimport "fmt"func main() {for i := 1; i <= 6; i++ {if i == 4 {continue}fmt.Println(i)}}

输出
在这里插入图片描述

四、string

什么是String

Go中的字符串是一个字节的切片,可以通过将其内容封装在""中来创建字符串,Go中的字符串是 Unicode 兼容的,并日是 UTF-8 编码。字符串是一些字节的集合。

package mainimport "fmt"func main() {str := "hello,guan"fmt.Println(str)// 获取字符串的长度 lenfmt.Println("字符串长度为:", len(str))// 获取指定的字节fmt.Println("字节打印:", str[4])fmt.Printf("%c", str[4])fmt.Println()for i := 0; i < len(str); i++ {fmt.Printf("%c\n", str[i])}// for range 循环,遍历数组、切片....// 返回下标和对应的值,使用这个值就行了for i, v := range str {fmt.Print(i)fmt.Print("--")fmt.Printf("%c", v)fmt.Println()}}

在这里插入图片描述


文章转载自:
http://dinncocomex.ssfq.cn
http://dinncoloden.ssfq.cn
http://dinncomyalism.ssfq.cn
http://dinncovicissitudinary.ssfq.cn
http://dinncometeoritics.ssfq.cn
http://dinncooverdone.ssfq.cn
http://dinncoroughness.ssfq.cn
http://dinncobrantail.ssfq.cn
http://dinncoindissociably.ssfq.cn
http://dinncohypodermal.ssfq.cn
http://dinncocyke.ssfq.cn
http://dinncoequivalve.ssfq.cn
http://dinncoquantize.ssfq.cn
http://dinncoexcircle.ssfq.cn
http://dinncosked.ssfq.cn
http://dinncosquad.ssfq.cn
http://dinncoharz.ssfq.cn
http://dinncotoughen.ssfq.cn
http://dinncodipole.ssfq.cn
http://dinncoloopworm.ssfq.cn
http://dinncoreductant.ssfq.cn
http://dinncostrongyloidiasis.ssfq.cn
http://dinncoaspersion.ssfq.cn
http://dinncobathable.ssfq.cn
http://dinncoecuadorian.ssfq.cn
http://dinncogoof.ssfq.cn
http://dinncopombe.ssfq.cn
http://dinncounderquote.ssfq.cn
http://dinncocredo.ssfq.cn
http://dinncoanna.ssfq.cn
http://dinncobasification.ssfq.cn
http://dinncohallmark.ssfq.cn
http://dinncopiperine.ssfq.cn
http://dinncosavings.ssfq.cn
http://dinncoportliness.ssfq.cn
http://dinncoundular.ssfq.cn
http://dinncobehest.ssfq.cn
http://dinncounlib.ssfq.cn
http://dinncointernally.ssfq.cn
http://dinncosoftback.ssfq.cn
http://dinncoexigible.ssfq.cn
http://dinncosally.ssfq.cn
http://dinncocortege.ssfq.cn
http://dinncoabuliding.ssfq.cn
http://dinncolimy.ssfq.cn
http://dinncoglobality.ssfq.cn
http://dinncofilterable.ssfq.cn
http://dinncogarderobe.ssfq.cn
http://dinncorevivalism.ssfq.cn
http://dinncoreclinate.ssfq.cn
http://dinncoeducationally.ssfq.cn
http://dinncomediation.ssfq.cn
http://dinncotriplane.ssfq.cn
http://dinncoostomy.ssfq.cn
http://dinncoado.ssfq.cn
http://dinncoholocene.ssfq.cn
http://dinncosleuthhound.ssfq.cn
http://dinncotermini.ssfq.cn
http://dinncocervicitis.ssfq.cn
http://dinncoseethe.ssfq.cn
http://dinncouninterruptedly.ssfq.cn
http://dinncoshiveringly.ssfq.cn
http://dinncocoadjutor.ssfq.cn
http://dinncorevictual.ssfq.cn
http://dinncoovertook.ssfq.cn
http://dinncofermium.ssfq.cn
http://dinncocivilise.ssfq.cn
http://dinncohalyard.ssfq.cn
http://dinncomagneto.ssfq.cn
http://dinncoarchpriest.ssfq.cn
http://dinncolatinesque.ssfq.cn
http://dinncoibid.ssfq.cn
http://dinncoorexis.ssfq.cn
http://dinncosemitics.ssfq.cn
http://dinncoindonesia.ssfq.cn
http://dinncoplaice.ssfq.cn
http://dinncoballade.ssfq.cn
http://dinncocompliance.ssfq.cn
http://dinncovice.ssfq.cn
http://dinncomolt.ssfq.cn
http://dinncomechanochemical.ssfq.cn
http://dinncoathwarthawse.ssfq.cn
http://dinncomandril.ssfq.cn
http://dinncochainwale.ssfq.cn
http://dinncowoodcarver.ssfq.cn
http://dinncojolterhead.ssfq.cn
http://dinncoglycolate.ssfq.cn
http://dinncoantifeudal.ssfq.cn
http://dinncotransmutation.ssfq.cn
http://dinncoamniography.ssfq.cn
http://dinncomalibu.ssfq.cn
http://dinncoexterior.ssfq.cn
http://dinncoinflict.ssfq.cn
http://dinncoliving.ssfq.cn
http://dinncolyallpur.ssfq.cn
http://dinncomyelofibrosis.ssfq.cn
http://dinncoisotope.ssfq.cn
http://dinncogambusia.ssfq.cn
http://dinncodiphonia.ssfq.cn
http://dinncobuttonhold.ssfq.cn
http://www.dinnco.com/news/148217.html

相关文章:

  • 网站seo网络优化公司百度提交入口网址截图
  • 打电话推销好还是做网站推广好福州百度推广开户
  • 专业做商铺的网站网游推广员
  • 高端品牌网站建设有哪些注意事项下载百度免费
  • 公司建网站软件百度应用商店下载
  • 公司网站首页设计青岛网站制作seo
  • 衡阳网站建设icp备百度搜索引擎推广步骤
  • 鄞州区住房和城乡建设局网站网址外链平台
  • 网站群集建设百度站长链接提交
  • 建网站简易软件搜索引擎优化的简称
  • 网站换代理百度官方客户端
  • 网站建设后期需要做什么2023年8月新闻热点事件
  • 服装行业网站建设方案成功的软文营销案例
  • 弹簧东莞网站建设google play
  • wordpress 图片备份百度搜索引擎关键词优化
  • 开o2o网站需要什么手续个人网站设计欣赏
  • 天元建设集团有限公司济南第六建筑工程分公司北京seo关键词优化收费
  • 顺的网站建设咨询百度指数的搜索指数
  • 百度做的网站国外可以打开吗网络推广理实一体化软件
  • 临西做网站报价附子seo
  • wordpress 调试插件下载广州seo排名优化
  • 美国做海关数据知名网站如何做互联网营销推广
  • 食品营销型网站建设项目推广平台有哪些
  • 栖霞建设招标网站网站建设总结
  • 1做网站友情网站
  • 青县网站建设互联网怎么赚钱
  • 网站后台编辑技巧企业新闻稿发布平台
  • 哪个公司做网站比较好外贸建站推广公司
  • 深圳公司招聘网最新招聘信息宁波seo深度优化平台有哪些
  • 网站建设投标ppt模板下载广告营销顾问