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.

36 lines
653 B

package main
//This solution is the placeholder of the student solution
// for an exercise in the exam asking for a Function
//Remember the disclaimer!!!!
//1) here the package is main
//2) It does need an empty func main(){}
type NodeAddL struct {
Next *NodeAddL
Num int
}
func pushFront(node *NodeAddL, num int) *NodeAddL {
tmp := &NodeAddL{Num: num}
if node == nil {
return tmp
}
tmp.Next = node
return tmp
}
func Reverse(node *NodeAddL) *NodeAddL {
if node == nil {
return node
}
ans := &NodeAddL{Num: node.Num}
for tmp := node.Next; tmp != nil; tmp = tmp.Next {
ans = pushFront(ans, tmp.Num)
}
return ans
}
func main() {
}