Skip to content

Commit

Permalink
Lab 4 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kokter committed Dec 2, 2023
1 parent f71dbe3 commit 9026efd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions golang/internal/lab4/calculate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ func Form(x, a float64) float64 {
}

func TaskA(Xs, Xe, step, a float64) ([]float64, []float64) {
y := []float64{}
x := []float64{}
y := make([]float64, 0, (int((Xe-Xs)/step - 1)))
x := make([]float64, 0, (int((Xe-Xs)/step - 1)))
for i := Xs; i <= Xe; i += step {
y = append(y, Form(i, a))
x = append(x, i)
Expand All @@ -17,8 +17,8 @@ func TaskA(Xs, Xe, step, a float64) ([]float64, []float64) {
}

func TaskB(a float64, xArr []float64) ([]float64, []float64) {
x := []float64{}
y := []float64{}
x := make([]float64, 0, len(xArr))
y := make([]float64, 0, len(xArr))
for _, i := range xArr {
y = append(y, Form(i, a))
x = append(x, i)
Expand Down
5 changes: 4 additions & 1 deletion golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (

func main() {
a := 2.25
Xs := 1.2
Xe := 2.7
step := 0.3
fmt.Println("Задача A")
x, y := lab4.TaskA(1.2, 2.7, 0.3, a)
x, y := lab4.TaskA(Xs, Xe, step, a)
for i := range y {
fmt.Println("При x=", x[i], "y=", y[i])
}
Expand Down

0 comments on commit 9026efd

Please sign in to comment.