mirror of https://github.com/01-edu/public.git
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.
87 lines
1.1 KiB
87 lines
1.1 KiB
6 years ago
|
## enigma
|
||
6 years ago
|
|
||
6 years ago
|
### Instructions
|
||
6 years ago
|
|
||
|
Write a function called `Enigma` that receives poiters to functions and move its values around to hide them
|
||
|
|
||
|
This function will put a into c; c into d; d into b and b into a
|
||
|
|
||
|
This function must have the following signature.
|
||
|
|
||
6 years ago
|
### Expected function
|
||
6 years ago
|
|
||
|
```go
|
||
|
func Enigma(a ***int, b *int, c *******int, d ****int) {
|
||
|
|
||
6 years ago
|
}
|
||
6 years ago
|
```
|
||
|
|
||
6 years ago
|
### Usage
|
||
6 years ago
|
|
||
|
Here is a possible [program](TODO-LINK) to test your function :
|
||
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
|
import (
|
||
6 years ago
|
"fmt"
|
||
|
student ".."
|
||
6 years ago
|
)
|
||
|
|
||
|
func main() {
|
||
|
x := 5
|
||
|
y := &x
|
||
|
z := &y
|
||
|
a := &z
|
||
|
|
||
|
w := 2
|
||
|
b := &w
|
||
|
|
||
|
u := 7
|
||
|
e := &u
|
||
|
f := &e
|
||
|
g := &f
|
||
|
h := &g
|
||
|
i := &h
|
||
|
j := &i
|
||
|
c := &j
|
||
|
|
||
|
k := 6
|
||
|
l := &k
|
||
|
m := &l
|
||
|
n := &m
|
||
|
d := &n
|
||
|
|
||
|
fmt.Println(***a)
|
||
|
fmt.Println(*b)
|
||
|
fmt.Println(*******c)
|
||
|
fmt.Println(****d)
|
||
|
|
||
|
student.Enigma(a, b, c, d)
|
||
|
|
||
|
fmt.Println("After using Enigma")
|
||
|
fmt.Println(***a)
|
||
|
fmt.Println(*b)
|
||
|
fmt.Println(*******c)
|
||
|
fmt.Println(****d)
|
||
|
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output :
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/student/enigma$ go build
|
||
|
student@ubuntu:~/student/enigma$ ./enigma
|
||
|
5
|
||
|
2
|
||
|
7
|
||
|
6
|
||
|
After using Enigma
|
||
|
2
|
||
|
6
|
||
|
5
|
||
|
7
|
||
6 years ago
|
student@ubuntu:~/student/enigma$
|
||
6 years ago
|
```
|