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

莆田企业制作网站seo公司赚钱吗

莆田企业制作网站,seo公司赚钱吗,wordpress无法写入,用vb做网站导航栏文章目录 前言Go的学习资料链接 AC代码01 输出打印GP1 go的第一个程序 02 变量GP2 小明信息GP3 个人信息 03 常量GP4 国家名称 04 指针GP5 值和指针 05 字符串GP6 拼接字符串GP7 字符数量GP8 回文数 06 类型转换GP9 格式化字符串GP10 字符求和 07 运算符GP11 长方形的周长GP12 …

文章目录

  • 前言
    • Go的学习资料链接
  • AC代码
    • 01 输出打印
      • GP1 go的第一个程序
    • 02 变量
      • GP2 小明信息
      • GP3 个人信息
    • 03 常量
      • GP4 国家名称
    • 04 指针
      • GP5 值和指针
    • 05 字符串
      • GP6 拼接字符串
      • GP7 字符数量
      • GP8 回文数
    • 06 类型转换
      • GP9 格式化字符串
      • GP10 字符求和
    • 07 运算符
      • GP11 长方形的周长
      • GP12 温度转换
      • GP13 工程时间
      • GP14 器材采购
      • GP15 逻辑运算
      • GP16 位运算
      • GP17 联谊活动
    • 08 数组
      • GP18 保龄球
    • 09 切片
      • GP19 创建切片
      • GP20 切片复制
      • GP21 出队
      • GP22 评委打分
      • GP23 调整顺序
      • GP24 判断两个切片是否有相同的元素
      • GP25 合并有序数组
      • GP26 置衣柜
    • 10 map
      • GP27 成绩表
      • GP28 单词字符
      • GP29 字符串构成
      • GP30 不重复的数
    • 11 条件语句
      • GP31 年龄分段
      • GP32 成绩判定
      • GP33 游乐园门票
      • GP34 推箱子
    • 12 循环语句
      • GP35 乘法口诀表
      • GP36 坐标转换
      • GP37 质量检查
      • GP38 团队闯关
    • 13 函数
      • GP39 数字的阶乘
      • GP40 绝对值
      • GP41 加减乘除
    • 14 结构体
      • GP42 学生信息II
      • GP43 学生信息III
    • 15 接口
      • GP44 动物和老虎
    • 16 错误
      • GP45 网络延迟
      • GP46 体温异常
  • END

前言

本文为牛客的在线编程的GO语言入门题集的个人解析

链接:牛客网在线编程_语法篇_GO语言入门

本人主语言C/C++ 来这边刷一下GO的入门语法题,这个题库很基础很入门真的就是纯考GO语法

本文虽然是展示AC代码,但实际是为了记录GO的各种基础语法,便于以后遗忘了可以查看

牛客的环境是版本:Go 1.14

Go的学习资料链接

相关资料链接:

Go 语言教程 | 菜鸟教程 (runoob.com)

《Go 入门指南》 | Go 技术论坛 (learnku.com)

Go by Example 中文版 (gobyexample-cn.github.io)

7天用Go从零实现分布式缓存GeeCache | 极客兔兔 (geektutu.com)

Go 语言设计与实现 | Go 语言设计与实现 (draveness.me)

AC代码

01 输出打印

GP1 go的第一个程序

package mainimport ("fmt"
)func main() {fmt.Println("Hello World!")
}

02 变量

GP2 小明信息

package mainimport ("fmt"
)type Person struct {name stringage intsex bool
}func main() {man := Person{"小明", 23, true}fmt.Printf("%s\n%d\n%v\n", man.name, man.age, man.sex)
}

GP3 个人信息

package mainimport  "fmt"func main() {num, b := 0, falsefmt.Printf("\n%d\n%v\n", num, b)
}

03 常量

GP4 国家名称

package mainimport  "fmt"func main() {const (China = "中国"English = "英国"America = "美国")fmt.Println(China)fmt.Println(English)fmt.Println(America)
}

04 指针

go 里的指针,有时用起来更像引用

GP5 值和指针

package mainfunc equal( a int ,  b int ) []bool {return []bool{&a == &b, a == b}
}

05 字符串

GP6 拼接字符串

package main
// import "fmt"func join( s []string ) string {var str string// _ 占位符,不会报错for _, ss := range s {str += ss}return str
}

GP7 字符数量

package main
// import "fmt"func count( s string ) int {runes := []rune(s) return len(runes)
}

GP8 回文数

package main
import "strconv"func isPalindrome( x int ) bool {str := strconv.Itoa(x)i, j := 0, len(str) - 1for ; i < j && str[i] == str[j]; i, j = i + 1, j - 1 {}return i >= j
}

06 类型转换

GP9 格式化字符串

知识点:

Go 使用 import 关键字来导入包

Go 可以使用 fmt.Sprintf 来格式化字符串,fmt.Sprintf(格式化样式, 参数列表…),格式化样式如下:

%v 按值的本来值输出

%+v 在 %v 基础上,对结构体字段名和值进行展开

%#v 输出 Go 语言语法格式的值

%T 输出 Go 语言语法格式的类型和值

%% 输出 % 本体

%b 整型以二进制方式显示

%o 整型以八进制方式显示

%d 整型以十进制方式显示

%x 整型以十六进制方式显示

%X 整型以十六进制、字母大写方式显示

%U Unicode 字符

%f 浮点数

%p 指针,十六进制方式显示

package main
import "strconv"func formatstr( num int ) string {return strconv.Itoa(num)
}

GP10 字符求和

知识点:

golang strconv.ParseInt 是将字符串转换为数字的函数,参数1 数字的字符串形式,参数2 数字字符串的进制 比如二进制 八进制 十进制 十六进制,参数3 返回结果的bit大小 也就是int8 int16 int32 int64

package main
import "strconv"func sum( a string ,  b string ) string {anum, _ := strconv.Atoi(a)bnum, _ :=strconv.Atoi(b)return strconv.Itoa(anum + bnum)
}

07 运算符

GP11 长方形的周长

package main
// import "fmt"func perimeter( a int ,  b int ) int {return 2 * (a + b)
}

GP12 温度转换

package main
// import "fmt"func temperature( f float64 ) float64 {return (f - 32.0) / 1.8
}

GP13 工程时间

package mainimport ("fmt"
)
func main() {const Day = 97fmt.Println(Day / 7)fmt.Println(Day % 7)
}

GP14 器材采购

package main
import "sort"func compare( x int ,  y int ,  z int ) int {nums := []int{x, y, z}sort.Ints(nums)return nums[len(nums) - 1] - nums[0]
}

GP15 逻辑运算

package main
// import "fmt"func logicalOperation( a bool ,  b bool ) []bool {return []bool {a && b, a || b, !a, !b}
}

GP16 位运算

package main
// import "fmt"func bitOperate( a int ,  b int ) []int {return []int {a & b, a | b, a ^ b}
}

GP17 联谊活动

package main
// import "fmt"func odevity( x int ) bool {return (x & 1) == 0
}

08 数组

GP18 保龄球

package mainimport  "fmt"func main() {// ... 可加可不加arr := [...]int{2, 5, 4, 6, 5}fmt.Println(arr)
}

09 切片

GP19 创建切片

package main
// import "fmt"func makeslice( length int ,  capacity int ) []int {// 类似于vector 的长度和容量arr := make([]int, length, capacity)// for i := 0; i < length; i += 1 {for i, _ := range arr {arr[i] = i}return arr
}

GP20 切片复制

知识点:

copy :函数 copy 在两个 slice 间复制数据,复制长度以 len 小的为准。

两个 slice 可指向同一底层数组,允许元素区间重叠。

package main
// import "fmt"/* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可** * @param src int整型一维数组 源切片* @param des int整型一维数组 目的切片* @return int整型一维数组
*/
func sliceCopy( src []int ,  des []int ) []int {// 可以省略第三个参数des = make([]int, len(src), cap(src))// 有一个拷贝到前一个copy(des, src)return des
}

GP21 出队

知识点:

s|n| 切片s中索引位置为n的项
s|:| 从切片s的索引位置0到len(s)-1 处所获得的切片
s|low:| 从切片s的索引位置 low 到len(s)-1 处所获得的切片
s|:high| 从切片s的索引位置 0到high 处所获得的切片,len=high
s|low: high| 从切片s的素引位置 Iow 到high 处所获得的切片,len-high-low
s|low: high:max| 从切片s的素引位置 low 到high 处所获得的切片,len-high-low, cap=max-low

package main
// import "fmt"func deleteElement( s []int ,  index int ) []int {return append(s[:index], s[index + 1:]...)
}

GP22 评委打分

知识点:

goalng, int64最大值,最小值, 大小比较,多返回值
golang中有符号的最大值为math.MaxInt64,最小值为math.MinInt64
切片的遍历有两种方式,for循环和for range循环

package main
import "sort"func minAndMax( s []int ) []int {sort.Ints(s)return []int{s[0], s[len(s) - 1]}
}

GP23 调整顺序

知识点:

len(slice)求一个切片的长度

for循环遍历切片

golang提供了多重赋值的特性可以轻松实现变量的交换,变量一,变量二 := 变量二,变量一

package main
// import "fmt"func convert( s []int ) []int {n := len(s)for i := 0; i < n / 2; i += 1 {s[i], s[n - 1 - i] = s[n - 1 - i], s[i]}return s
}

GP24 判断两个切片是否有相同的元素

package main
// import "fmt"func equal( s1 []int ,  s2 []int ) bool {var n, m = len(s1), len(s2)if n != m {return false}for i := 0; i < n; i += 1 {if s1[i] != s2[i] {return false}}return true
}
package main
import "reflect"func equal( s1 []int ,  s2 []int ) bool {return reflect.DeepEqual(s1, s2)
}

GP25 合并有序数组

package main
// import "fmt"func merge( nums1 []int ,  m int ,  nums2 []int ,  n int ) []int {if m == 0 {return nums2} else if n == 0 {return nums1}i, j := m  - 1, n - 1for k := m + n - 1; i != 0 || j != 0; k += -1 {// else 不准另起一行if i == 0 {nums1[k] = nums2[j]j += -1} else if j == 0 {nums1[k] = nums1[i]i += -1} else {if nums1[i] > nums2[j] {nums1[k] = nums1[i]i += -1} else {nums1[k] = nums2[j]j += -1}}}return nums1
}

GP26 置衣柜

package mainimport  "fmt"func main() {fmt.Println([]string{"帽子", "围巾", "衣服", "裤子", "袜子"})
}

10 map

GP27 成绩表

package mainimport ("fmt"
)func main() {mp := map[string]int{"小明": 60, "小王": 70, "张三": 95, "张伟": 88, "李四": 98, "王五": 100}fmt.Println(mp)
}
package mainimport ("fmt"
)func main() {// 多行map最后一个键值对后面也必须加逗号mp := map[string]int{"小明": 60, "小王": 70, "张三": 95, "张伟": 88, "李四": 98, "王五": 100,}fmt.Println(mp)
}

GP28 单词字符

遍历字符串的每个字符

  • range(0, n - 1)
  • string -> []byte
package main
// import "fmt"func character( s string ) byte {cnt := map[byte]int{}var ans bytek := 0for _, b := range ([]byte)(s) {cnt[b] += 1if k < cnt[b] {k = cnt[b]ans = b}}return ans
}

GP29 字符串构成

package main
// import "fmt"func canConstruct( des string ,  src string ) bool {vis := map[byte]int{}for _, b := range ([]byte)(src) {vis[b] += 1}for _, b := range ([]byte)(des) {vis[b] += -1if vis[b] < 0 {return false}}return true
}

GP30 不重复的数

知识点:

1,map用make方式进行初始化
2,切片可以用[]int{}的方式进行初始化
3,for range遍历切片
4,_,ok :=map[key]的方式判断m中的key是否存在
5,切片用append方式进行追加

package main
import "sort"func getNoRepeat( s []int ) []int {cnt := map[int]int{}for _, x := range(s) {cnt[x] += 1}ans := make([]int, 0)for k, v := range cnt {if v == 1 {ans = append(ans, k)}}sort.Ints(ans)return ans
}

11 条件语句

GP31 年龄分段

package main
// import "fmt"func getAge( age int ) string {if age >= 0 && age < 1 {return "婴儿"} else if age >= 1 && age <= 4 {return "幼儿"} else if age >= 5 && age <= 11 {return "儿童"} else if age >= 12 && age <= 18 {return "少年"} else if age >= 19 && age <= 35 {return "青年"} else if age >= 36 && age <= 59 {return "中年"} else {return "老年"}
}
package mainfunc getAge(age int) string {// switch不会穿透,不是return也不会执行下一个caseswitch {case age > 59:return "老年"case age > 35:return "中年"case age > 18:return "青年"case age > 11:return "少年"case age > 4:return "儿童"default:return "幼儿"}
}

GP32 成绩判定

package main
// import "fmt"func judgeScore( score int ) string {switch  {case score < 60:return "不及格"case score < 80:return "中等"case score < 90:return "良好"default:return "优秀"}
}

GP33 游乐园门票

package main
// import "fmt"func ispay( hight float64 ) bool {if hight < 160.0 {return false} return true
}

GP34 推箱子

package main
// import "fmt"func pushBox( forwards string ) bool {x, y := 0, 0for _, b := range forwards {// 单引号表示字符switch b {case 'U':y += 1case 'D':y += -1case 'R':x += -1case 'L':x += 1}}return x == 0 && y == 0
}

12 循环语句

GP35 乘法口诀表

package mainimport "fmt"func main() {for i := 1; i <= 9; i += 1 {for j := 1; j <= i; j += 1 {fmt.Printf("%d*%d=%-3d", j, i, i * j)}fmt.Printf("\n")}
}

GP36 坐标转换

package main
// import "fmt"func transform( array [][]int ) []int {ans := []int{}n, m := len(array), len(array[0])// 遍历二维数组for i := 0; i < n; i += 1 {for j := 0; j < m; j += 1 {ans = append(ans, array[i][j])}}return ans
}
package main
// import "fmt"func transform( array [][]int ) []int {ans := []int{}n:= len(array)// 将一维数组展开for i := 0; i < n; i += 1 {ans = append(ans, array[i]...)}return ans
}

GP37 质量检查

package main
// import "fmt"func check( material []int ,  standard int ) []int {ans := []int{}for _, x := range material {if x >= standard {ans = append(ans, x)}}return ans
}

GP38 团队闯关

package mainfunc canPass( score []int ,  target int ) bool {for _, x := range score {if x > target {return true}}return false
}

13 函数

GP39 数字的阶乘

package main
// import "fmt"func factorial( i int ) int {if i == 0 {return 1}return i * factorial(i - 1)
}

GP40 绝对值

package main
import "math"func absfunc( x int ) int {// 入参,反参都是 floatreturn int(math.Abs(float64(x)))
}

GP41 加减乘除

package main
// import "fmt"func operate( a int ,  b int ) []int {return []int{a + b, a - b, a * b, a / b, a % b}
}

14 结构体

GP42 学生信息II

package mainimport ("fmt"
)type Student struct {name stringsex boolage intscore int
}func main() {xiaoming := Student{"小明", true, 23, 88}fmt.Println(xiaoming.name)fmt.Println(xiaoming.sex)fmt.Println(xiaoming.age)fmt.Println(xiaoming.score)
}

GP43 学生信息III

package mainimport ("fmt"
)type City struct {province stringcity     string
}type Student struct {name  stringsex   boolage   intscore intcity  City
}func main() {city := City{"湖南省", "长沙市"}xiaoming := Student{name: "小明", sex: true, age: 23, score: 88, city: city}fmt.Println(xiaoming.name)fmt.Println(xiaoming.sex)fmt.Println(xiaoming.age)fmt.Println(xiaoming.score)fmt.Println(xiaoming.city.province)fmt.Println(xiaoming.city.city)
}

15 接口

GP44 动物和老虎

package mainimport ("fmt"
)type Animal interface {sleep() stringeat()   string
}type Tiger struct {
}func (t Tiger) sleep() string {return "sleep"
}func (t Tiger) eat() string {return "eat"
}func main() {tiger := Tiger{}fmt.Println(tiger.sleep())fmt.Println(tiger.eat())
}

16 错误

注意:错误,异常这块我只是骗ac的

GP45 网络延迟

package main// 使用golang标准库包errors 来定义错误。
import "errors"func defineerr( ping int ) string {if ping > 100 {return errors.New("网络延迟").Error()}return ""
}

GP46 体温异常

package main
import "errors"func temperature( t float64 ) string {if t > 37.5 {return errors.New("体温异常").Error()}return ""
}



END


文章转载自:
http://dutiable.stph.cn
http://rockbird.stph.cn
http://brassage.stph.cn
http://hawkish.stph.cn
http://rating.stph.cn
http://deceased.stph.cn
http://surplus.stph.cn
http://integrand.stph.cn
http://subulate.stph.cn
http://ono.stph.cn
http://draconian.stph.cn
http://thickskinned.stph.cn
http://thermomotor.stph.cn
http://mess.stph.cn
http://prosody.stph.cn
http://speculative.stph.cn
http://gloze.stph.cn
http://hairpiece.stph.cn
http://ftc.stph.cn
http://pigment.stph.cn
http://construction.stph.cn
http://ellipsis.stph.cn
http://pother.stph.cn
http://nasopharyngeal.stph.cn
http://composing.stph.cn
http://iridology.stph.cn
http://shaggy.stph.cn
http://twelvemo.stph.cn
http://salamander.stph.cn
http://adenine.stph.cn
http://benignancy.stph.cn
http://computerese.stph.cn
http://ablebodied.stph.cn
http://exhalent.stph.cn
http://figuresome.stph.cn
http://legatary.stph.cn
http://paperboard.stph.cn
http://quadrangled.stph.cn
http://kjv.stph.cn
http://quizzable.stph.cn
http://pitiless.stph.cn
http://aeromotor.stph.cn
http://enactment.stph.cn
http://viagraph.stph.cn
http://wax.stph.cn
http://balsamroot.stph.cn
http://ecopornography.stph.cn
http://majestical.stph.cn
http://draegerman.stph.cn
http://lambent.stph.cn
http://wedgewise.stph.cn
http://finance.stph.cn
http://subsistence.stph.cn
http://mentally.stph.cn
http://juxtapose.stph.cn
http://adnation.stph.cn
http://overripe.stph.cn
http://concealment.stph.cn
http://congressite.stph.cn
http://preoccupation.stph.cn
http://laughton.stph.cn
http://yill.stph.cn
http://majesty.stph.cn
http://erotica.stph.cn
http://irresistibly.stph.cn
http://midinette.stph.cn
http://tinkerly.stph.cn
http://overreliance.stph.cn
http://mongolian.stph.cn
http://kopfring.stph.cn
http://bildungsroman.stph.cn
http://prismatoid.stph.cn
http://tapis.stph.cn
http://glady.stph.cn
http://palaeontography.stph.cn
http://shipborne.stph.cn
http://numskull.stph.cn
http://rajahship.stph.cn
http://ostracon.stph.cn
http://annatto.stph.cn
http://nile.stph.cn
http://fluoroplastic.stph.cn
http://meanings.stph.cn
http://kavass.stph.cn
http://sanforize.stph.cn
http://osprey.stph.cn
http://francophone.stph.cn
http://drollery.stph.cn
http://imaginal.stph.cn
http://mitigative.stph.cn
http://catarrh.stph.cn
http://continental.stph.cn
http://umbrette.stph.cn
http://multangular.stph.cn
http://saintess.stph.cn
http://hypothermal.stph.cn
http://hexachord.stph.cn
http://sensibility.stph.cn
http://soda.stph.cn
http://firehorse.stph.cn
http://www.15wanjia.com/news/60007.html

相关文章:

  • 做网站要源代码学电商运营的培训机构
  • 学做川菜下什么网站百度官网下载安装到桌面上
  • wordpress 文章 页面整站seo定制
  • 网站规划阿里巴巴seo排名优化
  • 石家庄网站服务关键词优化公司费用多少
  • 保险公司网站建设方案福州百度快速优化
  • 电子商务网站开发是指培训网页
  • 长春百度网站快速优化海外网络专线
  • 网站更换服务器教程公司网络营销实施计划
  • 帮别人做网站怎么备案关键词自动生成器
  • 济南网站制作价格关键词权重如何打造
  • wix网站怎么做滚动全网seo优化电话
  • 网站建设有几种方式百度有几种推广方式
  • 淮安网站建设公司百度地图疫情实时动态
  • 陕西省建设网流程优化四个方法
  • python做电子商务网站网络公司推广方案
  • 众创空间那个网站做的好网络营销网站有哪些
  • 外贸网站建设长沙网站推广的基本方法
  • 广州网站推广排名竞价交易
  • 做一个交易平台网站的成本seo资源网站排名
  • 移动微网站开发阿里云建站费用
  • 企业网站需求方案google关键词查询工具
  • 合肥网站制作网站微信朋友圈广告推广
  • 网站的模块电商关键词工具
  • 推广的网站网络运营培训课程
  • 网站备案 互联网信息一周热点新闻
  • eaccelerator wordpress谷歌seo网站推广怎么做优化
  • 公司的网站怎么运营新人跑业务怎么找客户
  • 网站开发后台数据怎么来阿里指数官网
  • 南京建筑信息平台baidu优化