当前位置:网站首页>100 cases of go language
100 cases of go language
2022-06-26 06:13:00 【An Muxi】
Go Language 100 Example exercises
I'm learning Python When , Have done the rookie tutorial 100 Example exercises , however Golang There are fewer exercises , But you can refer to Go Language Bible , There are some exercises in it , Decided to take the rookie tutorial Python100 Examples Go Brush the language again , Consolidate your knowledge ~
Novice tutorial Python100 example :https://www.runoob.com/python/python-100-examples.html
1. There are four numbers :1、2、3、4, How many different and unrepeated three digit numbers can be formed ? How many are each ?
package main
import "fmt"
// subject : There are four numbers :1、2、3、4, How many different and unrepeated three digit numbers can be formed ? How many are each ?
func main() {
for i:=1;i<=4;i++{
for j:=1;j<=4;j++{
for k:=1;k<=4;k++{
if (i!=j) && (i!=k) && (j!=k){
fmt.Print(i)
fmt.Print(j)
fmt.Print(k)
fmt.Println()
// If written fmt.Print(i,j,k) The output 1 2 3
}
}
}
}
}

2. The bonus paid by the enterprise is based on the profit commission . profits (I) Below or equal to 10 Ten thousand yuan , Bonus can be raised 10%; Profit is higher than 10 Ten thousand yuan , lower than 20 Ten thousand yuan , lower than 10 For the part of ten thousand yuan, press 10% Royalty , higher than 10 Part of ten thousand yuan , It's a percentage 7.5%;20 Wan to 40 Ten thousand hours , higher than 20 Part of ten thousand yuan , It's a percentage 5%;40 Wan to 60 Ten thousand times is higher than 40 Part of ten thousand yuan , It's a percentage 3%;60 Wan to 100 Ten thousand hours , higher than 60 Part of ten thousand yuan , It's a percentage 1.5%, higher than 100 Ten thousand yuan , exceed 100 For the part of ten thousand yuan, press 1% Royalty , Input the profit of the month from the keyboard I, Ask for the total amount of bonus payable ?
package main
import "fmt"
func main() {
// It's here for convenience , All defined as float32 type
var i float32
fmt.Print(" Please enter enterprise net profit :")
fmt.Scanln(&i)
arr := []float32{
1000000,600000,400000,200000,100000,0}
rat := []float32{
0.01,0.015,0.03,0.05,0.075,0.1}
r := float32(0)
for idx:=0;idx<len(arr);idx++{
if i>arr[idx]{
r = r + (i-arr[idx])*rat[idx] // Calculate the bonus part
}
}
fmt.Printf(" The total amount of bonus paid is :%.2f",i+r)
}

3. An integer , It adds
100And then there's a complete square , Plus268It's a complete square again , What is the number ?
Be careful : There is a problem with the title of the novice tutorial , Should be268No168
package main
import (
"fmt"
"math"
)
func main() {
i := 0
for i<100000{
x := int(math.Sqrt(float64(i+ 100)))
y := int(math.Sqrt(float64(i+ 268)))
if x*x == i+100 && y*y == i+268 {
fmt.Printf(" The number is %d\n", i)
}
i++
}
}

To be updated …
边栏推荐
- Implement the runnable interface
- Tencent WXG internship experience (has offered), I hope it will help you!
- E-commerce seeks growth breakthrough with the help of small program technology
- Efk Upgrade to clickhouse log Storage Reality
- Logstash -- send an alert message to the nail using the throttle filter
- How to design a good technical scheme
- Data visualization practice: Data Visualization
- How to use the tablet as the second extended screen of the PC
- MySQL-07
- Matching environment of ES6
猜你喜欢

【群内问题学期汇总】初学者的部分参考问题

Handwritten background management framework template (I)

canal部署、原理和使用介绍

Detailed explanation of serial port communication principle 232, 422, 485

跨域的五种解决方案

Mysql-10 (key)

5 minutes to learn regular expressions

Logstash - logstash pushes data to redis

Combined mode, transparent mode and secure mode

EFK昇級到ClickHouse的日志存儲實戰
随机推荐
Bubble sort
EFK升级到ClickHouse的日志存储实战
Logstash - logstash sends an alarm email to email
【Spark】Spark SQL 字段血缘如何实现
421- binary tree (226. reversed binary tree, 101. symmetric binary tree, 104. maximum depth of binary tree, 222. number of nodes of complete binary tree)
Given two corresponding point sets AB, how to estimate the parameters of the specified transformation matrix R?
Mysql-10 (key)
Playing RTSP streaming video on Web pages (webrtc)
SQL Server 函数
Architecture design method
GoF23—抽象工厂模式
打印数字的位信息
数据可视化实战:数据可视化
302. 包含全部黑色像素的最小矩形 BFS
Data visualization practice: Data Visualization
GoF23—原型模式
通俗易懂的从IDE说起,再谈谈小程序IDE
The difference between abstract and interface interface
SQL Server视图
Factory method pattern, abstract factory pattern