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

Lab3 Lab4 Lab5 #217

Open
wants to merge 7 commits into
base: Soldatov_Ivan_Sergeevich
Choose a base branch
from
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
42 changes: 42 additions & 0 deletions golang/laba4/lab4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package lab4

import (
"fmt"
"math"
)

func Formula(a, x float64) float64 {
return ((math.Pow((math.Log(a + x)), 2)) / (math.Pow((a + x), 2)))
}

func TaskA(a, x_start, x_end, x_step float64) []float64 {
y := make([]float64, 0, int((x_end-x_start)/x_step))
for x := x_start; x <= x_end; x += x_step {
y = append(y, Formula(a, x))
}
return y
}

func TaskB(a float64, array []float64) []float64 {
y := make([]float64, 0, len(array))
for _, x := range array {
y = append(y, Formula(a, x))
}
return y
}

func output(results []float64) {
for _, i := range results {
fmt.Println(i)
}
}

func Solve(a, x_start, x_end, x_step float64) {
results := TaskA(a, x_start, x_end, x_step)
fmt.Println("Exercise_A:")
output(results)

results = TaskB(a, []float64{1.16, 1.32, 1.47, 1.65, 1.93})
fmt.Println("Exercise_В:")
output(results)
}
103 changes: 103 additions & 0 deletions golang/labb5/lab5.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package lab5

import (
"fmt"
)

type Mouse struct {
Name string
Age int64
Sex string
}

// funcGet
func (m Mouse) GetName() string {
return m.Name
}

func (m Mouse) GetAge() int64 {
return m.Age
}

func (m Mouse) GetSex() string {
return m.Sex
}

// funcSet
func (m *Mouse) SetName(name1 string) {
m.Name = name1
}

func (m *Mouse) SetAge(age int64) {
m.Age = age
}

func (m *Mouse) SetSex(sex string) {
m.Sex = sex
}

func NewMouse(name, sex string, age int64) (Mouse, string) {
var m Mouse = Mouse{
Name: name,
Age: age,
Sex: sex,
}
str := " "
if m.Age < 0 {
str = "Указанный возраст мышки явлется недопустимым"
return m, str
}
return m, str
}

func (m Mouse) GetInfo() {
fmt.Println("Name:", m.GetName())
fmt.Println("Age:", m.GetAge())
fmt.Println("Sex:", m.GetSex())
}

func (m Mouse) MickeyM() {
m.SetAge(92)
m.SetName("Mickey Mouse")
m.SetSex("Male")

m.GetInfo()

fmt.Println(` .--, .--,
( ( \.---./ ) )
'.__/o o\__.'
{= ^ =}
> '._.' <
___________.""-------"".____________
| o O \
| /
| . O Hello! I'm Mikkey Mouse =) o \
| / __
| \ _.-' '.
|______________o__________o__________/ .-~^ '~--'
___)( )(___ '-.___.'
(((__) (__)))`)
}

func (m Mouse) MinnieM() {
m.SetName("Minnie Mouse")
m.SetAge(82)
m.SetSex("Female")

m.GetInfo()

fmt.Println(` .--, .--,
( ( \.---./ ) )
'.__/o o\__.'
{= ^ =}
> '._.' <
___________.""-------"".____________
| o O \
| /
| . O Hello! I'm Minnie Mouse ;) o \
| / __
| \ _.-' '.
|______________o__________o__________/ .-~^ '~--'
___)( )(___ '-.___.'
(((__) (__)))`)
}
22 changes: 21 additions & 1 deletion golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
package main

import "fmt"
import (
"fmt"

lab4 "isuct.ru/informatics2022/laba4"
lab5 "isuct.ru/informatics2022/labb5"
)

func main() {
mouse, err := lab5.NewMouse("Mickey", "Male", 92)
if err != " " {
fmt.Println(err)
}
mouse.MickeyM()

mouse.MinnieM()

fmt.Println("Солдатов Иван Сергеевич")
fmt.Println("------------------------First_Exercise-------------------------------")
a := 2.0
x_end := 4.2
x_step := 0.6
x_start := 1.2

lab4.Solve(a, x_start, x_end, x_step)
}