Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Вот сюда нужно будет в первой работе с гитом добавит свое ФИО

## ФИО
## Иванов Алексей Алексеевич

## Работа с репозиторием

Expand Down
2 changes: 0 additions & 2 deletions golang/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module isuct.ru/informatics2022

go 1.16

require github.com/stretchr/testify v1.8.1
17 changes: 0 additions & 17 deletions golang/go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
3 changes: 3 additions & 0 deletions golang/informatics.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"path": "."
},
{
"path": "../../../Struct test"
}
],
"settings": {
"files.exclude": {
Expand Down
43 changes: 43 additions & 0 deletions golang/internal/plane/plane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package plane

import "fmt"

type plane struct {
speed int
model string
color string
}

func NewPlane(model_name, color string, speed int) (plane, error) {
var p plane = plane{
model: model_name,
}
var err = p.SetSpeed(speed)
p.SetColor(color)
return p, err
}

func (p *plane) SetSpeed(plane_speed int) error {
if plane_speed <= 3529 && plane_speed >= 0 {
p.speed = plane_speed
return nil
} else {
return fmt.Errorf("Самолет не может лететь c такой скоростью")
}
}

func (p *plane) GetSpeed() int {
return p.speed
}

func (p *plane) SetColor(plane_color string) {
p.color = plane_color
}

func (p *plane) GetColor() string {
return p.color
}

func (p *plane) GetModel() string {
return p.model
}
40 changes: 40 additions & 0 deletions golang/internal/sample.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
package internal

import (
"fmt"
"math"
)

func Summ(a, b int) int {
return a + b
}

const a = 1.1
const b = 0.09

func down(x, a, b float64) float64 {
arg := a*x*x - b
base := 5.0
return math.Log(arg) / math.Log(base)
}

func up(x float64) float64 {
return math.Log(x*x*x - 1)
}

func SolveB(numbers []float64) []float64 {
fmt.Println("\n Задача B:")
var resultB []float64 = make([]float64, 0, len(numbers))
for x := 0; x <= 4; x++ {
upf := up(numbers[x])
downf := down(numbers[x], a, b)
resultB = append(resultB, upf/downf)
}
return resultB
}

func SolveA(a, b, xn, xk, dx float64) []float64 {
fmt.Println("Задача A:")
var resultA []float64 = make([]float64, 0, int(((xk-xn)/dx + 1)))
for x := xn; x <= xk; x += dx {
upf := up(x)
downf := down(x, a, b)
resultA = append(resultA, upf/downf)
}
return resultA
}
34 changes: 32 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
package main

import "fmt"
import (
"fmt"

"isuct.ru/informatics2022/internal/plane"

"isuct.ru/informatics2022/internal"
)

func main() {
fmt.Println("Hello world")
fmt.Println("Иванов Алексей Алексеевич 1/278")
fmt.Println(internal.SolveA(1.1, 0.09, 1.2, 2.2, 0.2))
fmt.Println(internal.SolveB([]float64{4.48, 3.56, 2.78, 5.28, 3.21}))
// planeStruct Lab5
fmt.Printf("\n First Plane: \n")
plane1, err := plane.NewPlane("Космолёт", "Фиолетовый", 3124)
if err != nil {
fmt.Printf("%v", err)
}
fmt.Println(plane1.GetModel())
fmt.Println(plane1.GetColor())
plane1.SetColor("Белый")
fmt.Println(plane1.GetColor())
fmt.Println(plane1.GetSpeed())
plane1.SetSpeed(3400)
fmt.Println(plane1.GetSpeed())
fmt.Printf("\n Second Plane: \n")
plane2, err := plane.NewPlane("Boeing 737", "Серый", 400)
if err != nil {
fmt.Printf("%v", err)
}
fmt.Println(plane2.GetModel())
fmt.Println(plane2.GetColor())
plane2.SetColor("Красный")
fmt.Println(plane2.GetColor())
}