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

Lab4,6 #603

Open
wants to merge 9 commits into
base: Gretchenko_Vladislav
Choose a base branch
from
34 changes: 34 additions & 0 deletions golang/lab4/lab4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package lab4

import (
"fmt"
"math"
)

func Calculate(x float64) float64 {
if math.Abs(x) >= 1 {
return (math.Pow(1.2, x)) - (math.Pow(x, 1.2))
}
return math.Acos(x)
}

func TaskA(Xmin, Xmax, Xdel float64) []float64 {
var y []float64
for x := Xmin; x <= Xmax; x += Xdel {
y = append(y, Calculate(x))
}
return y
}

func TaskB(x [5]float64) []float64 {
var y []float64
for _, value := range x {
y = append(y, Calculate(value))
}
return y
}
Comment on lines +8 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нет смысла делать их публичными, вы используете их только внутри пакета


func Runlab4() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

CamelCase соблюдайте во всем проекте

fmt.Println(TaskA(0.2, 2.2, 0.4))
fmt.Println(TaskB([5]float64{0.1, 0.9, 1.2, 1.5, 1.3}))
}
30 changes: 30 additions & 0 deletions golang/lab6/lab6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package lab6

import "fmt"

type Phone struct {
Name string
Op string
Number string
}

func NewPhone(name, op, number string) *Phone {
p := new(Phone)
p.Name = name
p.Op = op
p.Number = number
return p
}

func (p *Phone) SetNumber(number string) { p.Number = number }
func (p Phone) GetNumber() string { return p.Number }
func (p Phone) GetOp() string { return p.Op }
func (p Phone) GetName() string { return p.Name }

func Runlab6() {
phone := NewPhone("Влад", "Билайн", "89621658549")
phone.SetNumber("89012863969")
fmt.Println("Имя владельца:", phone.GetName())
fmt.Println("Оператор сотовой связи:", phone.GetOp())
fmt.Println("Номер телефона пользователя:", phone.GetNumber())
}
11 changes: 9 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package main

import "fmt"
import (
"fmt"

lab4 "isuct.ru/informatics2022/lab4"
lab6 "isuct.ru/informatics2022/lab6"
)

func main() {
fmt.Println("Гретченко Владислав")
fmt.Println("Гретченко Владислав Игоревич")
lab4.Runlab4()
lab6.Runlab6()
}
Loading