Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Боков Кирилл 1/42 - Сделал оставшиеся функции, исправил ошибки #148

Open
wants to merge 6 commits into
base: Bokov_Kirill_Mihajlovich
Choose a base branch
from
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Репозиторий для работ по курсу информатика

Вот сюда нужно будет в первой работе с гитом добавит свое ФИО
Боков Кирилл Михайлович

## ФИО

Expand Down
9 changes: 9 additions & 0 deletions golang/evenorodd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

func evenorodd(number int) string {
if ((number % 2) != 0) {
return "Odd"
} else {
return "Even"
}
}
5 changes: 5 additions & 0 deletions golang/hero.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

func hero(bullets, dragons int) bool {
return bullets/dragons >= 2
}
13 changes: 13 additions & 0 deletions golang/lab.go
Original file line number Diff line number Diff line change
@@ -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
}
}
30 changes: 28 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
package main

import "fmt"
import (
"fmt"
)

func main() {
fmt.Println("Hello world")
//Лабораторная
for x := 3.5; x <= 6.5; x = 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))
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}}))
}
9 changes: 9 additions & 0 deletions golang/monkeys.go
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 15 additions & 0 deletions golang/narray.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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}
}
}
8 changes: 8 additions & 0 deletions golang/paper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

func paper(n, m int) int {
if n < 0 || m < 0 {
return 0
}
return (n * m)
}
17 changes: 17 additions & 0 deletions golang/polish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"strings"
)

func polish(inps string) string {
pa := []string{"ą", "ć", "ę", "ł", "ń", "ó", "ś", "ź", "ż"}
ea := []string{"a", "c", "e", "l", "n", "o", "s", "z", "z"}
inpscopy := inps
for i := 0; i < len(inps); i++ {
for j := 0; j < len(pa); j++ {
inpscopy = strings.ReplaceAll(inpscopy, pa[j], ea[j])
}
}
return inpscopy
}
11 changes: 11 additions & 0 deletions golang/sheeps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

func sheeps(slice []bool) int {
nmofsheeps := 0
for i := 0; i < len(slice); i++ {
if slice[i] {
nmofsheeps++
}
}
return nmofsheeps
}
15 changes: 15 additions & 0 deletions golang/sumofmin.go
Original file line number Diff line number Diff line change
@@ -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
}