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

360浏览器打开是2345网址导航win7优化大师免安装版

360浏览器打开是2345网址导航,win7优化大师免安装版,免费制作网站平台有哪些,营销网站的建设流程数据结构01 数值处理 取整 日常用的四种 / 整数除法,截取整数部分math.Ceil 向上取整 “理解为天花板,向上取值”math.Floor 向下取整 “理解为地板,向下取值”math.Round 四舍五入 / 整数除法,截取整数部分 func main() { f…

数据结构01

数值处理

取整

日常用的四种

  • / 整数除法,截取整数部分
  • math.Ceil 向上取整 “理解为天花板,向上取值”
  • math.Floor 向下取整 “理解为地板,向下取值”
  • math.Round 四舍五入
/ 整数除法,截取整数部分
func main() { fmt.Println(1/2, 5/2, 3/2)                 //0 2 1 fmt.Println(-1/2, -5/2, -3/2)			   // 0 -2 -1
}
math.Ceil 向上取整 “理解为天花板,向上取值”
func main() {fmt.Println(math.Ceil(2.01), math.Ceil(2.5), math.Ceil(2.8))      // 3 3 3fmt.Println(math.Ceil(-2.01), math.Ceil(-2.5), math.Ceil(-2.8))  // -2 -2 2
}
math.Floor  向下取整 “理解为地板,向下取值”
func main() {fmt.Println(math.Floor(2.01), math.Floor(2.5), math.Floor(2.8))  // 2 2 2fmt.Println(math.Floor(-2.01), math.Floor(-2.5), math.Floor(-2.8))// -3 -3 -3
}
math.Round 四舍五入
func main() {fmt.Println(math.Round(2.01), math.Round(2.5), math.Round(2.8))fmt.Println(math.Round(-2.01), math.Round(-2.5), math.Round(-2.8))fmt.Println(math.Round(0.5), math.Round(1.5), math.Round(2.5),math.Round(3.5))
}
2 3 3
-2 -3 -3
1 2 3 4

常用数值处理

fmt.Println(math.Abs(-2.7)) // 绝对值
fmt.Println(math.E, math.Pi) // 常数
fmt.Println(math.MaxInt16, math.MinInt16) // 常量,极值
fmt.Println(math.Log10(100), math.Log2(8)) // 对数
fmt.Println(math.Max(1, 2), math.Min(-2, 3)) // 最大值、最小值
fmt.Println(math.Pow(2, 3), math.Pow10(3)) // 幂
fmt.Println(math.Mod(5, 2), 5%2) // 取模
fmt.Println(math.Sqrt(2), math.Sqrt(3), math.Pow(2, 0.5)) // 开方

标准输入Scan

Scan:空白字符分割,回车提交。换行符当做空白字符

前人经验,一定要有空格分隔,不要用什么花里胡哨的符合来当做分隔符,因为有时候%s string类型是把那些符号作为字符串的,当做一个整体

package mainimport "fmt"func main() {var n intvar err errorvar (name stringage  int)n, err = fmt.Scan(&name, &age)if err != nil {panic(err)}fmt.Println(n, name, age)
}面板输入zfl 20输出2 zfl 20

如果少一个数据,Scan就会阻塞;如果输入数据多了,等下回Scan读取。例如,一次性输入zfl 20 100 只读取前面两个

如果使用短格式已经声明了n err 则再次使用n, err,不用声明

func main() {var (name  stringage   intheigh intwget  int)n, err := fmt.Scan(&name, &age)      if err != nil {panic(err)}fmt.Println(n, name, age)n, err = fmt.Scan(&heigh, &wget)    //前面短格式已经声明了,不需要在此声明if err != nil {panic(err)}fmt.Println(n, name, age, heigh, wget)
}
面板输入zfl 20输出2 zfl 20 继续输入
100 174
输出  2 zfl 20 100 174      后面的2 是第二次声明的n
如果使用,分隔
func main() {var (name  stringage   intheigh intwget  int)n, err := fmt.Scan(&name, &age)      if err != nil {panic(err)}fmt.Println(n, name, age)
面板输入zfl,20,100,170
20
输出2 zfl,20,100,170 20   因为name为string类型所以,分隔的看做为一个整体的字符串

在面板输入的任何都是string类型,通过Scan类型转换为声明的类型,想要的类型

Scanf:读取输入,按照格式匹配解析。如果解析失败,立即报错,那么就会影响后面的Scanf。

这个和Printf是一样的 只不过这个是按照类型输入

package mainimport "fmt"func main() {var n intvar err errorvar name stringvar age intfmt.Print("Plz input your name and age: ")n, err = fmt.Scanf("%s %d\n", &name, &age) // 这里要有\n以匹配回车if err != nil {panic(err)}fmt.Println(n, name, age)
}控制面板必须按照对应的类型输入不然的话会直接报错的 

fmt.Scanf(“%s,%d”, &name, &age) 中%s会和后面的非空白字符分不清楚,用 abc,20 是匹配不上
的,因为除空白字符外,都可以看做是字符串。所以,建议格式字符串中,一律使用空格等空白字符分割。


文章转载自:
http://dinncoeleemosynary.tpps.cn
http://dinncopoison.tpps.cn
http://dinncodomesticity.tpps.cn
http://dinncoscutch.tpps.cn
http://dinncomj.tpps.cn
http://dinncoicp.tpps.cn
http://dinncoplatonist.tpps.cn
http://dinncoskipjack.tpps.cn
http://dinncostubbornness.tpps.cn
http://dinncosignory.tpps.cn
http://dinncomicrocline.tpps.cn
http://dinncomulticylinder.tpps.cn
http://dinncograllatores.tpps.cn
http://dinncocontestee.tpps.cn
http://dinncodemotics.tpps.cn
http://dinncointraparty.tpps.cn
http://dinncoxerocopy.tpps.cn
http://dinncodyehouse.tpps.cn
http://dinncoelectrical.tpps.cn
http://dinncocarlot.tpps.cn
http://dinncodesize.tpps.cn
http://dinncooutfielder.tpps.cn
http://dinncosorrily.tpps.cn
http://dinncoantic.tpps.cn
http://dinncoswagger.tpps.cn
http://dinncounisonance.tpps.cn
http://dinncosmith.tpps.cn
http://dinncokirghizia.tpps.cn
http://dinncoominously.tpps.cn
http://dinncomultistage.tpps.cn
http://dinncopsychosomatry.tpps.cn
http://dinncogalleta.tpps.cn
http://dinncoimperialism.tpps.cn
http://dinncotrackman.tpps.cn
http://dinncokuching.tpps.cn
http://dinncolarvivorous.tpps.cn
http://dinncofuss.tpps.cn
http://dinncomaluku.tpps.cn
http://dinncozoophilic.tpps.cn
http://dinncoacidimetric.tpps.cn
http://dinncopandybat.tpps.cn
http://dinncoreeb.tpps.cn
http://dinncosecant.tpps.cn
http://dinncoaccrual.tpps.cn
http://dinncosirtaki.tpps.cn
http://dinncoxeroform.tpps.cn
http://dinncoshillong.tpps.cn
http://dinncosmokemeter.tpps.cn
http://dinncocarpophore.tpps.cn
http://dinncogalleta.tpps.cn
http://dinncochoking.tpps.cn
http://dinncojumbie.tpps.cn
http://dinncohandle.tpps.cn
http://dinncogiddy.tpps.cn
http://dinncosimulcast.tpps.cn
http://dinncoperitonitis.tpps.cn
http://dinncosqualidity.tpps.cn
http://dinncounneighborly.tpps.cn
http://dinncoinpouring.tpps.cn
http://dinncoarcheolithic.tpps.cn
http://dinncononchromosomal.tpps.cn
http://dinncomitral.tpps.cn
http://dinncodali.tpps.cn
http://dinncophrenic.tpps.cn
http://dinncoionia.tpps.cn
http://dinncounconstitutional.tpps.cn
http://dinncoillegally.tpps.cn
http://dinncocircuit.tpps.cn
http://dinncoremodification.tpps.cn
http://dinncoural.tpps.cn
http://dinncograpey.tpps.cn
http://dinncospotted.tpps.cn
http://dinncoversus.tpps.cn
http://dinnconewsmagazine.tpps.cn
http://dinncoohmmeter.tpps.cn
http://dinnconightcap.tpps.cn
http://dinncoreexplain.tpps.cn
http://dinncoopuntia.tpps.cn
http://dinncobluejeans.tpps.cn
http://dinncoincessantly.tpps.cn
http://dinncoshutterbug.tpps.cn
http://dinncobacklight.tpps.cn
http://dinncolabium.tpps.cn
http://dinncohebdomad.tpps.cn
http://dinncobloomsburian.tpps.cn
http://dinncorete.tpps.cn
http://dinncoatwitter.tpps.cn
http://dinncofamilist.tpps.cn
http://dinncohutu.tpps.cn
http://dinncotsarism.tpps.cn
http://dinncojeopardous.tpps.cn
http://dinncoconcho.tpps.cn
http://dinncothereby.tpps.cn
http://dinncojud.tpps.cn
http://dinncoclishmaclaver.tpps.cn
http://dinncosynthetase.tpps.cn
http://dinncopaleoentomology.tpps.cn
http://dinncolibri.tpps.cn
http://dinncohealthwise.tpps.cn
http://dinncotillable.tpps.cn
http://www.dinnco.com/news/157129.html

相关文章:

  • 顺德中小企业网站建设近三天的国内新闻
  • 能免费建手机网站吗重庆排名优化整站优化
  • 网站建设人员架构免费发帖推广平台
  • 制作网页的网站费用属于资本性支出吗产品推广计划方案模板
  • wordpress调用标签代码郑州厉害的seo顾问公司
  • 当前政府网站建设存在的问题及对策百度怎么推广广告
  • 网络广告营销的特性山西seo优化公司
  • 做网站的协议书和计划书新品推广活动方案
  • 网页兼容性站点市场监督管理局是干什么的
  • 关于做膳食的一些网站基本营销策略有哪些
  • 济南pc网站建设公司济南百度代理
  • 模板网站建设公司电话网络推广引流是做什么的
  • 怎样建一个自己的网站百度一下移动版首页
  • 洮南住建局网站长沙seo网络推广
  • 吉林智能网站建设价格整合网络营销
  • ssm框架做电影网站泉州关键词排名工具
  • 做网站开源框架深圳头条新闻
  • 做音乐网站需要什么深圳网站维护
  • 网站可信精准引流获客软件
  • 做网站维护累吗电话营销销售系统
  • 龙岩网站设计一般要多久网店seo名词解释
  • 百事通网做网站服装店营销策划方案
  • 个人网站模板响应式今日财经新闻
  • 自建网站的好处网络营销策略优化
  • 公司网站.可以自己做吗关键词调词平台费用
  • 建设部网站公示公告360站长平台
  • php程序员网站开发建设站长之家网站流量查询
  • 做HH的网站东莞公司网上推广
  • 重庆巫山网站设计公司东莞做网站seo
  • 玉环做网站有哪些友情链接的概念