Skip to content
Open

Lab 6 #598

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
27 changes: 27 additions & 0 deletions golang/lab4/lab4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package lab4

import "math"

const a = 0.4
const b = 0.8
Comment on lines +5 to +6

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Параметры функций, должны быть переданы при вызове в Task_A и Task_B


func calculateY(a, b, x float64) float64 {
var y float64 = (math.Pow(a, x) - math.Pow(b, x)) / (math.Log10(a/b) * math.Cbrt(a*b))
return y
}

func Task_A(xn, xk, delx float64) []float64 {
var yValues []float64
for x := xn; x <= xk; x += delx {
yValues = append(yValues, calculateY(a, b, x))
}
return yValues
}

func Task_B(xv []float64) []float64 {
var yValues []float64
for _, x := range xv {
yValues = append(yValues, calculateY(a, b, x))
}
return yValues
}
46 changes: 46 additions & 0 deletions golang/lab6/lab6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package lab6

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все поменять


import (
"fmt"
)

type TV struct {
Channel int

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут не хватает еще 2 полей

}

func NewTV(channel int) *TV {
tv := new(TV)
tv.Channel = channel
return tv
}

func (t *TV) GetChannel() int {
return t.Channel
}

func (t *TV) SetChannel(channel int) {
if channel > 0 {
t.Channel = channel
fmt.Printf("Channel set to %d\n", channel)
} else {
fmt.Println("Invalid channel number")
}
}

func (t *TV) Display() {
fmt.Println("╔════════════════╗")
fmt.Println("║ ║")
fmt.Printf("║ Channel %2d ║\n", t.GetChannel())
fmt.Println("║ ║")
fmt.Println("╚════════════════╝")
fmt.Println(" || ")
fmt.Println(" ==== ")
}

func Lab6() {
samsung := NewTV(2)
samsung.SetChannel(5)
samsung.Display()
samsung.SetChannel(12)
samsung.Display()
}
13 changes: 11 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package main

import "fmt"
import (
"fmt"

"isuct.ru/informatics2022/lab4"

"isuct.ru/informatics2022/lab6"
)

func main() {
fmt.Println("Hello world")
fmt.Println("Губе Владислав Семёнович")
fmt.Println("Task A:\n", lab4.Task_A(3.2, 6.2, 0.6))
fmt.Println("Task B:\n", lab4.Task_B([]float64{4.48, 3.56, 2.78, 5.28, 3.21}))
Comment on lines +13 to +14

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрать внутрь лабы 4

lab6.Lab6()
}