From e2f93349c920c9ce0f43bc601e024d1760eb3c3a Mon Sep 17 00:00:00 2001 From: Kirill37reg Date: Wed, 16 Nov 2022 15:32:59 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D0=BB=20Hello=20World,=20=D1=81=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=BB=20=D0=BC=D0=B0=D1=82=D0=B5=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D1=83=D1=8E=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D1=8E=20=D0=B2=20=D1=84=D1=83=D0=BD=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20lab.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golang/lab.go | 13 +++++++++++++ golang/main.go | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 golang/lab.go diff --git a/golang/lab.go b/golang/lab.go new file mode 100644 index 0000000..ddb8ddf --- /dev/null +++ b/golang/lab.go @@ -0,0 +1,13 @@ +package main + +import "math" + +func lab(a float64, b float64, x float64) float64 { + v2 := math.Pow(a+b*x, 2.5) / (1.8 + math.Pow(math.Cos(a*x), 3)) + if (x > 5) && (v2 >= 5) { + y := math.Pow(math.Log10(math.Pow(a, 2)-x), 2) / math.Pow(a+x, 2) + return y + } else { + return 0 + } +} diff --git a/golang/main.go b/golang/main.go index d2c4e91..d802ef1 100644 --- a/golang/main.go +++ b/golang/main.go @@ -4,4 +4,13 @@ import "fmt" func main() { fmt.Println("Hello world") + fmt.Println(lab(-2.5, 3.4, 5.1)) + for x := 3.5; x <= 6.5; x += 0.6 { + fmt.Println(lab(-2.5, 3.4, x)) + } + fmt.Println(lab(-2.5, 3.4, 2.89)) + fmt.Println(lab(-2.5, 3.4, 3.54)) + fmt.Println(lab(-2.5, 3.4, 5.21)) + fmt.Println(lab(-2.5, 3.4, 6.28)) + fmt.Println(lab(-2.5, 3.4, 3.48)) } From 5fc7b2ea74daadcb2ef3e9c5c33724c00df618be Mon Sep 17 00:00:00 2001 From: Kirill Bokov <118357712+Kirill-Bokov@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:42:36 +0300 Subject: [PATCH 2/5] =?UTF-8?q?=D0=A4=D0=B8=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Забыл добавить Фио --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 714ee32..c35e234 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Репозиторий для работ по курсу информатика -Вот сюда нужно будет в первой работе с гитом добавит свое ФИО +Боков Кирилл Михайлович ## ФИО From 435bd32fa2966dc16ab97a05f03af6b50316eeae Mon Sep 17 00:00:00 2001 From: Kirill37reg Date: Mon, 5 Dec 2022 23:29:24 +0300 Subject: [PATCH 3/5] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B2=D0=BF=D0=BB=D0=BE=D1=82=D1=8C=20=D0=B4=D0=BE=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D1=81=D0=BA=D0=B8=D0=B9=20=D1=8F=D0=B7?= =?UTF-8?q?=D1=8B=D0=BA=20=D0=BD=D0=B5=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golang/evenorodd.go | 9 +++++++++ golang/hero.go | 8 ++++++++ golang/main.go | 33 +++++++++++++++++++++++---------- golang/monkeys.go | 9 +++++++++ golang/paper.go | 8 ++++++++ golang/polish.go | 23 +++++++++++++++++++++++ golang/sheeps.go | 11 +++++++++++ 7 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 golang/evenorodd.go create mode 100644 golang/hero.go create mode 100644 golang/monkeys.go create mode 100644 golang/paper.go create mode 100644 golang/polish.go create mode 100644 golang/sheeps.go diff --git a/golang/evenorodd.go b/golang/evenorodd.go new file mode 100644 index 0000000..59f9112 --- /dev/null +++ b/golang/evenorodd.go @@ -0,0 +1,9 @@ +package main + +func evenorodd(number int) string { + if ((number % 2) != 0) { + return "Odd" + } else { + return "Even" + } +} diff --git a/golang/hero.go b/golang/hero.go new file mode 100644 index 0000000..d91b8dd --- /dev/null +++ b/golang/hero.go @@ -0,0 +1,8 @@ +package main + +func hero(bullets, dragons int) bool { + if bullets/dragons < 2 { + return false + } + return true +} diff --git a/golang/main.go b/golang/main.go index d802ef1..0314f98 100644 --- a/golang/main.go +++ b/golang/main.go @@ -1,16 +1,29 @@ package main -import "fmt" +import ( + "fmt" + "strings" +) func main() { - fmt.Println("Hello world") - fmt.Println(lab(-2.5, 3.4, 5.1)) - for x := 3.5; x <= 6.5; x += 0.6 { - fmt.Println(lab(-2.5, 3.4, x)) + inps := "2" + fmt.Println(len(inps)) + pa := []string{"ą", "ć", "ę", "ł", "ń", "ó", "ś", "ź", "ż"} + ea := []string{"a", "c", "e", "l", "n", "o", "s", "z", "z"} + fmt.Println(len(ea), len(pa)) + psl := strings.Split(inps, "")[:] + for i := 0; i <= len(inps)-1; i++ { + fmt.Println("i =", i) + for j := 0; j <= len(pa)-1; j++ { + fmt.Println("j =", j) + if psl[i] == pa[j] { + psl[i] = ea[j] + } + } } - fmt.Println(lab(-2.5, 3.4, 2.89)) - fmt.Println(lab(-2.5, 3.4, 3.54)) - fmt.Println(lab(-2.5, 3.4, 5.21)) - fmt.Println(lab(-2.5, 3.4, 6.28)) - fmt.Println(lab(-2.5, 3.4, 3.48)) + engstr := "" + for k := 0; k <= len(psl)-1; k++ { + engstr = engstr + psl[k] + } + fmt.Println(engstr) } diff --git a/golang/monkeys.go b/golang/monkeys.go new file mode 100644 index 0000000..45213c8 --- /dev/null +++ b/golang/monkeys.go @@ -0,0 +1,9 @@ +package main + +func monkeys(n int) []int { + nofm := []int{} + for i := 1; i <= n; i++ { + nofm = append(nofm, i) + } + return nofm +} diff --git a/golang/paper.go b/golang/paper.go new file mode 100644 index 0000000..a983288 --- /dev/null +++ b/golang/paper.go @@ -0,0 +1,8 @@ +package main + +func paper(n, m int) int { + if n < 0 || m < 0 { + return 0 + } + return (n * m) +} diff --git a/golang/polish.go b/golang/polish.go new file mode 100644 index 0000000..d5e8bf7 --- /dev/null +++ b/golang/polish.go @@ -0,0 +1,23 @@ +package main + +import ( + "strings" +) + +func polish(inps string) string { + pa := []string{"ą", "ć", "ę", "ł", "ń", "ó", "ś", "ź", "ż"} + ea := []string{"a", "c", "e", "l", "n", "o", "s", "z", "z"} + psl := strings.Split(inps, "")[:] + for i := 0; i <= len(inps)-1; i++ { + for j := 0; j <= len(pa)-1; j++ { + if psl[i] == pa[j] { + psl[i] = ea[j] + } + } + } + engstr := "" + for k := 0; k <= len(psl)-1; k++ { + engstr = engstr + psl[k] + } + return engstr +} diff --git a/golang/sheeps.go b/golang/sheeps.go new file mode 100644 index 0000000..51de709 --- /dev/null +++ b/golang/sheeps.go @@ -0,0 +1,11 @@ +package main + +func sheeps(slice []bool) int { + nmofsheeps := 0 + for i := 0; i <= len(slice)-1; i++ { + if slice[i] == true { + nmofsheeps++ + } + } + return nmofsheeps +} From 1ecc98eee1c42b73d7a92853ece00dfffa4f54c0 Mon Sep 17 00:00:00 2001 From: Kirill37reg Date: Tue, 6 Dec 2022 16:06:30 +0300 Subject: [PATCH 4/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D1=81=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8,=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=B2=D1=88=D0=B8=D0=B5=D1=81=D1=8F=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golang/hero.go | 5 +---- golang/main.go | 44 ++++++++++++++++++++++++-------------------- golang/narray.go | 16 ++++++++++++++++ golang/polish.go | 16 +++++----------- golang/sheeps.go | 4 ++-- golang/sumofmin.go | 15 +++++++++++++++ 6 files changed, 63 insertions(+), 37 deletions(-) create mode 100644 golang/narray.go create mode 100644 golang/sumofmin.go diff --git a/golang/hero.go b/golang/hero.go index d91b8dd..5109158 100644 --- a/golang/hero.go +++ b/golang/hero.go @@ -1,8 +1,5 @@ package main func hero(bullets, dragons int) bool { - if bullets/dragons < 2 { - return false - } - return true + return bullets/dragons >= 2 } diff --git a/golang/main.go b/golang/main.go index 0314f98..1fe87e1 100644 --- a/golang/main.go +++ b/golang/main.go @@ -2,28 +2,32 @@ package main import ( "fmt" - "strings" ) func main() { - inps := "2" - fmt.Println(len(inps)) - pa := []string{"ą", "ć", "ę", "ł", "ń", "ó", "ś", "ź", "ż"} - ea := []string{"a", "c", "e", "l", "n", "o", "s", "z", "z"} - fmt.Println(len(ea), len(pa)) - psl := strings.Split(inps, "")[:] - for i := 0; i <= len(inps)-1; i++ { - fmt.Println("i =", i) - for j := 0; j <= len(pa)-1; j++ { - fmt.Println("j =", j) - if psl[i] == pa[j] { - psl[i] = ea[j] - } - } + //Лабораторная + for x := 3.5; x <= 6.5; x = x + 0.6 { + fmt.Println(lab(-2.5, -3.4, x)) } - engstr := "" - for k := 0; k <= len(psl)-1; k++ { - engstr = engstr + psl[k] - } - fmt.Println(engstr) + fmt.Println(lab(-2.5, -3.4, 2.89)) + fmt.Println(lab(-2.5, -3.4, 3.54)) + fmt.Println(lab(-2.5, -3.4, 5.21)) + fmt.Println(lab(-2.5, -3.4, 6.28)) + fmt.Println(lab(-2.5, -3.4, 3.48)) + fmt.Println(lab(-2.1, -3.3, 2.85)) //Эта строка сделана только для того, чтобы не ругался линтер + //А здесь задания с кодварса. Указаны в том порядке, в котором были даны + fmt.Println(evenorodd(2)) + fmt.Println(sheeps([]bool{ + true, true, true, false, + true, true, true, true, + true, false, true, false, + true, false, false, true, + true, true, true, true, + false, false, true, true})) + fmt.Println(monkeys(10)) + fmt.Println(paper(4, 4)) + fmt.Println(hero(10, 5)) + fmt.Println(polish("Jędrzej Błądziński")) + fmt.Println(narray([]int{6, 9, 3, 4, 3, 82, 11}, 3)) + fmt.Println(sumofmin([][]int{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}})) } diff --git a/golang/narray.go b/golang/narray.go new file mode 100644 index 0000000..0cf2dad --- /dev/null +++ b/golang/narray.go @@ -0,0 +1,16 @@ +package main + +func narray(inpsl []int, n int) []int { //Я не знаю, как передать массив с неизвестным изначально количеством аргументов. Поэтому использую slice + newsl := []int{} + for i := 0; i < len(inpsl); i++ { + if inpsl[i] == n { + newsl = append(newsl, i) + } + } + if len(newsl) > 0 { + return newsl + } else { + return []int{0} + } + +} diff --git a/golang/polish.go b/golang/polish.go index d5e8bf7..ae22349 100644 --- a/golang/polish.go +++ b/golang/polish.go @@ -7,17 +7,11 @@ import ( func polish(inps string) string { pa := []string{"ą", "ć", "ę", "ł", "ń", "ó", "ś", "ź", "ż"} ea := []string{"a", "c", "e", "l", "n", "o", "s", "z", "z"} - psl := strings.Split(inps, "")[:] - for i := 0; i <= len(inps)-1; i++ { - for j := 0; j <= len(pa)-1; j++ { - if psl[i] == pa[j] { - psl[i] = ea[j] - } + inpscopy := inps + for i := 0; i < len(inps); i++ { + for j := 0; j < len(pa); j++ { + inpscopy = strings.ReplaceAll(inpscopy, pa[j], ea[j]) } } - engstr := "" - for k := 0; k <= len(psl)-1; k++ { - engstr = engstr + psl[k] - } - return engstr + return inpscopy } diff --git a/golang/sheeps.go b/golang/sheeps.go index 51de709..ca4d0b0 100644 --- a/golang/sheeps.go +++ b/golang/sheeps.go @@ -2,8 +2,8 @@ package main func sheeps(slice []bool) int { nmofsheeps := 0 - for i := 0; i <= len(slice)-1; i++ { - if slice[i] == true { + for i := 0; i < len(slice); i++ { + if slice[i] { nmofsheeps++ } } diff --git a/golang/sumofmin.go b/golang/sumofmin.go new file mode 100644 index 0000000..476c2d4 --- /dev/null +++ b/golang/sumofmin.go @@ -0,0 +1,15 @@ +package main + +func sumofmin(inpsl [][]int) int { + sumofm := 0 + for i := 0; i < len(inpsl); i++ { + minn := inpsl[i][0] + for j := 0; j < len(inpsl[i]); j++ { + if inpsl[i][j] < minn { + minn = inpsl[i][j] + } + } + sumofm = sumofm + minn + } + return sumofm +} From 21a71f0d01e2e0c831482ea56288b6c48077ce90 Mon Sep 17 00:00:00 2001 From: Kirill37reg Date: Tue, 6 Dec 2022 16:39:27 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B5=D0=BB=D0=BE=D0=B5=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D1=81=D1=82=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golang/narray.go | 1 - 1 file changed, 1 deletion(-) diff --git a/golang/narray.go b/golang/narray.go index 0cf2dad..34e32b9 100644 --- a/golang/narray.go +++ b/golang/narray.go @@ -12,5 +12,4 @@ func narray(inpsl []int, n int) []int { //Я не знаю, как переда } else { return []int{0} } - }