added new file go/l12.go for work map and update README.md in go folder

This commit is contained in:
hhu67 2026-06-06 16:50:30 +03:00
parent 7c5926b97a
commit 55225686f1
3 changed files with 34 additions and 1 deletions

View file

@ -23,3 +23,10 @@ sort:
sort.Sort(sort.Reverse(sort.ТипПеременной(x))) - для сортировки по убыванию
reflect:
reflect.DeepEqual(x1, x2) - для сравнения срезов
os:
.Exit(0/1) - для принудительного завершения программы
map:
map[ТипКлюча]ТипЗначения{} - для объчвления map
delete(x, "Ключ") - для удаления элемента из map
x1[x2] = x3 - для добавления элемента в map
value, ok := x1[x2] - для проверки существования элемнта в map, ok = true/false, value = значению x1[x2]

26
go/l12.go Normal file
View file

@ -0,0 +1,26 @@
package main
import (
"fmt"
)
func main() {
mape := map[int]string{
1: "sergey",
2: "sergay",
}
fmt.Println("Введите свое имя")
var pol string
fmt.Scanln(&pol)
mape[len(mape)+1] = pol
fmt.Println("Ваше имя:",mape[len(mape)])
fmt.Println("Введите число значение каторого хотите увидеть")
var i int
fmt.Scan(&i)
value, ok := mape[i]
if ok {
fmt.Println(value)
} else {
fmt.Println("значение",i,"не найдено, значение поиска:",ok)
}
}

BIN
go/output/l12 Executable file

Binary file not shown.