Try to print the pattern in two sections: Upper half followed with lower half, it would be easier to print. But remember that total number of lines in the output is 9, so consider this condition carefully.
Hint: Use if and else condition along with && operators. Calculate column numbers in program depending upon the number of rows provide in the input.