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.
78 lines
1.0 KiB
78 lines
1.0 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
5 years ago
|
import (
|
||
5 years ago
|
student "student"
|
||
|
|
||
|
"lib"
|
||
5 years ago
|
)
|
||
5 years ago
|
|
||
|
// Helper function used in the test for checking the function Enigma()
|
||
5 years ago
|
func decrypt(a ***int, b *int, c *******int, d ****int) {
|
||
5 years ago
|
vala := ***a
|
||
|
***a = *******c
|
||
|
valb := *b
|
||
|
*b = vala
|
||
|
vald := ****d
|
||
|
****d = valb
|
||
|
*******c = vald
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
args := lib.MultRandIntBetween(2, 20)
|
||
5 years ago
|
|
||
|
aval := args[0]
|
||
|
x := args[0]
|
||
|
y := &x
|
||
|
z := &y
|
||
|
a := &z
|
||
|
|
||
|
bval := args[1]
|
||
|
w := args[1]
|
||
|
b := &w
|
||
|
|
||
|
cval := args[2]
|
||
|
u := args[2]
|
||
|
e := &u
|
||
|
f := &e
|
||
|
g := &f
|
||
|
h := &g
|
||
|
i := &h
|
||
|
j := &i
|
||
|
c := &j
|
||
|
|
||
|
dval := args[3]
|
||
|
k := args[3]
|
||
|
l := &k
|
||
|
m := &l
|
||
|
n := &m
|
||
|
d := &n
|
||
|
|
||
|
student.Enigma(a, b, c, d)
|
||
5 years ago
|
decrypt(a, b, c, d)
|
||
5 years ago
|
|
||
|
if aval != ***a {
|
||
5 years ago
|
lib.Fatalf("Expected ***a = %d instead of %d\n",
|
||
5 years ago
|
aval,
|
||
|
***a,
|
||
|
)
|
||
|
}
|
||
|
if bval != *b {
|
||
5 years ago
|
lib.Fatalf("Expected *b = %d instead of %d\n",
|
||
5 years ago
|
bval,
|
||
|
*b,
|
||
|
)
|
||
|
}
|
||
|
if cval != *******c {
|
||
5 years ago
|
lib.Fatalf("Expected *******c = %d instead of %d\n",
|
||
5 years ago
|
cval,
|
||
|
*******c,
|
||
|
)
|
||
|
}
|
||
|
if dval != ****d {
|
||
5 years ago
|
lib.Fatalf("Expected ****d = %d instead of %d\n",
|
||
5 years ago
|
dval,
|
||
|
****d,
|
||
|
)
|
||
|
}
|
||
|
}
|