forked from root/public
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.
90 lines
1.0 KiB
90 lines
1.0 KiB
5 years ago
|
## enigma
|
||
5 years ago
|
|
||
5 years ago
|
### Instructions
|
||
![]()
5 years ago
|
|
||
5 years ago
|
Write a function called `Enigma` that receives pointers to as arguments and move its values around to hide them.
|
||
![]()
5 years ago
|
|
||
5 years ago
|
This function will put :
|
||
|
|
||
5 years ago
|
- `a` into `c`.
|
||
|
- `c` into `d`.
|
||
|
- `d` into `b`.
|
||
|
- `b` into `a`.
|
||
![]()
5 years ago
|
|
||
5 years ago
|
### Expected function
|
||
![]()
5 years ago
|
|
||
|
```go
|
||
|
func Enigma(a ***int, b *int, c *******int, d ****int) {
|
||
|
|
||
5 years ago
|
}
|
||
![]()
5 years ago
|
```
|
||
|
|
||
5 years ago
|
### Usage
|
||
![]()
5 years ago
|
|
||
5 years ago
|
Here is a possible program to test your function :
|
||
![]()
5 years ago
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
|
import (
|
||
5 years ago
|
"fmt"
|
||
5 years ago
|
piscine ".."
|
||
![]()
5 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)
|
||
|
|
||
![]()
5 years ago
|
piscine.Enigma(a, b, c, d)
|
||
![]()
5 years ago
|
|
||
|
fmt.Println("After using Enigma")
|
||
|
fmt.Println(***a)
|
||
|
fmt.Println(*b)
|
||
|
fmt.Println(*******c)
|
||
|
fmt.Println(****d)
|
||
|
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output :
|
||
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./test
|
||
![]()
5 years ago
|
5
|
||
|
2
|
||
|
7
|
||
|
6
|
||
|
After using Enigma
|
||
|
2
|
||
|
6
|
||
|
5
|
||
|
7
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$
|
||
![]()
5 years ago
|
```
|