Lets guess the output have too many lines
for( j=i+1; j<=4; j++){
cout<<j;
cout<<'\n'; }
cout<<'\n';
Your program is complicated and for size 4 only.
a little analyze should help to get it better. The diamond have a vertical and horizontal symmetry, all is around the center (1)
Size Rows Cols Center
1 1 1 0,0
2 3 3 1,1
3 5 5 2,2
4 7 7 3,3
Should not be complicated to store the Size in a variable and reduce Rows, Cols and Center.
You can notice that all '2' are at a distance of 1 col or 1 row from center.
'3' are 1 step further: distance in rows + distance in cols give you the value at position.
if value is more the the size, print a space.
I let you fill the holes as an exercise.
Advice:
- Learn one or more analyze methods, E.W. Djikstra/N. Wirth
Stepwize Refinment/top-Down method is a good start.
Structured Programming.pdf[
^]
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[
^]
https://en.wikipedia.org/wiki/Structured_programming[
^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[
^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[
^]