-
Notifications
You must be signed in to change notification settings - Fork 110
Lab 6 #598
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
base: Gube_Vladislav
Are you sure you want to change the base?
Lab 6 #598
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| 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 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package lab6 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Все поменять |
||
|
|
||
| import ( | ||
| "fmt" | ||
| ) | ||
|
|
||
| type TV struct { | ||
| Channel int | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
| } | ||
| 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Убрать внутрь лабы 4 |
||
| lab6.Lab6() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Параметры функций, должны быть переданы при вызове в Task_A и Task_B