EC Sailing The Seas (Function-Array)
EC Sailing The Seas (Function-Array)
EC Sailing The Seas (Function-Array)
- Populates the array with tilde ‘~’, period ‘.’ and the ‘S’ character
so that if you output the array (nested loop) it looks like this:
~ . . . . . . . . .
~ ~ . . . . . . . .
~ ~ ~ . . . . . . .
~ ~ ~ ~ . . . . . .
~ ~ ~ ~ ~ . . . . .
~ ~ ~ ~ ~ S . . . .
~ ~ ~ ~ ~ ~ ~ . . .
~ ~ ~ ~ ~ ~ ~ ~ . .
~ ~ ~ ~ ~ ~ ~ ~ ~ .
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
- This display is a map, where ‘~’ represents the ocean, ‘.’ Represents
land and the ‘S’ represents a ship that is sailing on the ocean.
- The ‘S’ should be at located in array 6 at position 6 (5,5).
Note that coordinate 5,5 on this display is location 6,6 in the
array. There is an offset that you need to account for.
0 ~ . . . . . . . . .
1 ~ ~ . . . . . . . .
2 ~ ~ ~ . . . . . . .
3 ~ ~ ~ ~ . . . . . .
4 ~ ~ ~ ~ ~ . . . . .
5 ~ ~ ~ ~ ~ S . . . .
6 ~ ~ ~ ~ ~ ~ ~ . . .
7 ~ ~ ~ ~ ~ ~ ~ ~ . .
8 ~ ~ ~ ~ ~ ~ ~ ~ ~ .
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
0 1 2 3 4 5 6 7 8 9
(n)orth
(s)outh
(e)ast
(w)est
N
W E
S
n)orth
s)outh
e)ast
w)est
~ . . . . . . . . .
~ ~ . . . . . . . .
~ ~ ~ . . . . . . .
~ ~ ~ ~ . . . . . .
~ ~ ~ ~ ~ . . . . .
~ ~ ~ ~ ~ ~ . . . .
~ ~ ~ ~ ~ S ~ . . .
~ ~ ~ ~ ~ ~ ~ ~ . .
~ ~ ~ ~ ~ ~ ~ ~ ~ .
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
0 1 2 3 4 5 6 7 8 9
n)orth
s)outh
e)ast
w)est
~ . . . . . . . . .
~ ~ . . . . . . . .
~ ~ ~ . .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