Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
makhotinna committed Dec 1, 2023
1 parent d30af8e commit 7a28889
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
27 changes: 13 additions & 14 deletions golang/internal/lab4/lab4.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import (
)

func Task1(a, b, xn, xk, deltax float64) []float64 {
var answers1 []float64 = make([]float64, 0)
for x := xn; x <= xk; x += deltax {
y := (a + math.Pow(math.Tan(bx), 2)) / (b + math.Pow(math.Atan(ax), 2))
answers1 = append(answers1, y)
}
return answers1
var answers1 []float64 = make([]float64, 0)
for x := xn; x <= xk; x += deltax {
y := (a + math.Pow(math.Tan(b*x), 2)) / (b + math.Pow(math.Atan(a*x), 2))
answers1 = append(answers1, y)
}
return answers1
}

func Task2(a float64, b float64, znX []float64) []float64 {
var answers2 []float64 = make([]float64, 0)
for _, value := range znX {
x := value
y := (a + math.Pow(math.Tan(bx), 2)) / (b + math.Pow(math.Atan(ax), 2))
answers2 = append(answers2, y)
}
return answers2
}
var answers2 []float64 = make([]float64, 0)
for _, x := range znX {
y := (a + math.Pow(math.Tan(b*x), 2)) / (b + math.Pow(math.Atan(a*x), 2))
answers2 = append(answers2, y)
}
return answers2
}
14 changes: 9 additions & 5 deletions golang/internal/lab5/lab5.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

type city struct {
population int
country string
country string
}

func (c city) GetPopulation() int {
Expand All @@ -16,22 +16,26 @@ func (c city) GetPopulation() int {
func NewCity(setPopulation int, setCountry string) city {
return city{
population: setPopulation,
country: setCountry
country: setCountry,
}
}

func (c *city) SetCountry(country string) {
c.country = country
}

func (c *city) SetPopulation(population int) error {
if population >= 0 && population <= 400 {
c.population = population
return nil
}
return fmt.Errorf("Invalid city population")
return fmt.Errorf("invalid city population")
}

func (c city) GetCountry() string {
return c.country
}

func (c city) GetTheCity() {
func (c *city) GetTheCity() {
fmt.Println("Welcome!")
}
}
21 changes: 7 additions & 14 deletions golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ import (
"fmt"
"log"

"isuct.ru/informatics2022/internal/catStruct"
"isuct.ru/information2022/internal/lab4"
"isuct.ru/informatics2022/internal/lab4"
"isuct.ru/informatics2022/internal/lab5"
)

func printResult(xL []float64, yL [float64]) {
for i := range yL {
fnt.Printf("x = %.2f, y = %f\n", xL[i], yL[i])
}
}

func checkForError(err error) {
if err != nil {
log.Fatal(err)
Expand All @@ -24,12 +18,11 @@ func main() {
fmt.Println("Махотина Валерия Олеговна")
fmt.Println("---")

a1 := Task1(0.1, 0.5, 0.15, 1.37, 0.25)
a1 := lab4.Task1(0.1, 0.5, 0.15, 1.37, 0.25)
fmt.Print(a1)
fmt.Println("---")

a2 := Task2(0.1, 0.5, []float64{0.2, 0.3, 0.44, 0.6, 0.56})
fmt.Println(a2)
a2 := lab4.Task2(0.1, 0.5, []float64{0.2, 0.3, 0.44, 0.6, 0.56})
fmt.Println(a2)

var city = lab5.NewCity(400, "Russia")

Expand All @@ -40,5 +33,5 @@ func main() {

fmt.Printf("City's population is %d\n", city.GetPopulation())
fmt.Printf("This city is in %s\n", city.GetCountry())
fmt.GetTheCity()
}
city.GetTheCity()
}

0 comments on commit 7a28889

Please sign in to comment.