Skip to content

Commit

Permalink
calculation func fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaputmeoy committed Jan 9, 2024
1 parent e1cee88 commit f55153f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
33 changes: 33 additions & 0 deletions golang/internal/sample.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
package internal

import (
"math"
)

func Summ(a, b int) int {
return a + b
}

const a = 0.8
const b = 0.4

func Calc(start, finish, delta float64) []float64 {
var slice = make([]float64, 0, int64((finish-start)/delta+1))
for x := start; x <= finish; x += delta {
slice = append(slice, problem1(a, b, x))
}
return slice
}

func Calcmassiw(long []float64) []float64 {
var answer = make([]float64, 0, len(long))
for _, val := range long {
answer = append(answer, problem1(a, b, val))
}
return answer
}

func problem1(a, b, x float64) float64 {
result := (math.Pow(math.Pow((x-a), 2), drob(3.0)) + math.Pow(math.Abs(x+b), drob(5.0))) / (math.Pow((math.Pow(x, 2) - math.Pow((a+b), 2)), drob(9.0)))
return result
}

func drob(y float64) float64 {
result_1 := 1 / y
return result_1
}
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"

"isuct.ru/informatics2022/internal"
)

func main() {
fmt.Println("Terenteva Anastasija")
fmt.Println("Терентьева Анастасия Романовна")

fmt.Println(internal.Calc(1.23, 7.23, 1.2))
fmt.Println(internal.Calcmassiw([]float64{1.88, 2.26, 3.84, 4.55, -6.21}))
}

0 comments on commit f55153f

Please sign in to comment.