05AB1E, 50 49 bytes
3mF9Ý.R}J¹ô¹ävy`¦'*ìN4%©>ir}®iRr}®<iR})ˆ}¯øvyðý}»
Explanation
Examples for input = 4.
First we create a string of input^3 random numbers between 0 and 9.
3mF9Ý.R}J
producing
6799762549425893341317984133999075245812305412010122884262903656
Then we split that into pieces each the size of the input.
That is further split into input pieces.
¹ô¹ä
This gives us a matrix of numbers.
[['6799', '7625', '4942', '5893'],
['3413', '1798', '4133', '9990'],
['7524', '5812', '3054', '1201'],
['0122', '8842', '6290', '3656']]
We then loop over the rows of the matrix, inserting asterisks in the right places.
v } # for each row in matrix
y` # flatten list to stack
¦'*ì # replace the first digit of the last number with "*"
N4%©>ir} # if row-nr % 4 == 0, move the number with "*" to the front
®iRr} # if row-nr % 4 == 1, move the number with "*" to the front
# and reverse the number, moving "*" to the numbers right side
®<iR} # if row-nr % 4 == 2, reverse the number, moving "*"
# to the numbers right side
)ˆ # wrap row in a list and add to global array
Now we have the matrix with a "*" on each row, but we want an asterisk per column.
[['*893', '4942', '7625', '6799'],
['099*', '4133', '1798', '3413'],
['7524', '5812', '3054', '102*'],
['0122', '8842', '6290', '*656']]
So we zip this list turning rows into columns and vice versa.
[['*893', '099*', '7524', '0122'],
['4942', '4133', '5812', '8842'],
['7625', '1798', '3054', '6290'],
['6799', '3413', '102*', '*656']]
All that's left now is to format the output.
vyðý}»
Joining the rows on spaces and the columns on newlines gives us the final result.
*893 099* 7524 0122
4942 4133 5812 8842
7625 1798 3054 6290
6799 3413 102* *656
Try it online!
Old 50 byte solution
F¹Fõ¹F9Ý.R«}}¦'*ì})¹ävyN4%©>iR}®iíÁ}®<ií}})øvyðý}»
*
s in then=4
example? Perhaps give some more examples? \$\endgroup\$*153
, the second with the top row*135
, and so on. \$\endgroup\$