You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
689 B
45 lines
689 B
6 months ago
|
package cap4
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestEx14(t *testing.T) {
|
||
|
result := Ex15([]int{-1})
|
||
|
println(result)
|
||
|
}
|
||
|
|
||
|
func TestEx24(t *testing.T) {
|
||
|
nums := [][]int{
|
||
|
{9},
|
||
|
{12, 15},
|
||
|
{10, 6, 8},
|
||
|
{2, 18, 9, 5},
|
||
|
{19, 7, 10, 4, 16},
|
||
|
}
|
||
|
result, steps := Ex24(nums)
|
||
|
println(result)
|
||
|
for _, step := range steps {
|
||
|
fmt.Printf("%d ", step)
|
||
|
}
|
||
|
println()
|
||
|
}
|
||
|
|
||
|
func TestEx28(t *testing.T) {
|
||
|
nums := []int{3, 18, 7, 14, 10, 12, 23, 41, 16, 24}
|
||
|
result := Ex28(nums)
|
||
|
fmt.Println(result)
|
||
|
}
|
||
|
|
||
|
func PrintEx26Answer(s [][]int, i, j int) {
|
||
|
if i == j {
|
||
|
fmt.Printf("A%d", i)
|
||
|
} else {
|
||
|
fmt.Print("(")
|
||
|
PrintEx26Answer(s, i, s[i][j])
|
||
|
PrintEx26Answer(s, s[i][j]+1, j)
|
||
|
fmt.Print(")")
|
||
|
}
|
||
|
}
|