I would do it this way:
Initialize a 5x5 two-dimensional array of integers to 0. Have a direction
variable, and define constants or an enum
for the four directions. Start moving 'right' from (0, 0), filling in the array with increasing values until you hit the edge or a number that is not 0. Then, increment the direction (and wrap) and continue. Then print the array in rows.
An alternative using loops is to iterate over all the (x, y) coordinates, and pass x and y into a function that gives you the value at that position. The function I wrote does exactly the same thing as would the function that fills the array, except it doesn't write to an array, and when it reaches the given (x, y) it returns the current value. Not very efficient, but it achieves the result.