It is easy if you use a bunch of if...else statements, work it out yourself.
If you want a better solution, first ask yourself what pattern do you see in the figures.
For example in the "X", the position of the asterisks in the i-th row are at the i-th column and the (6-i)th column.