Pattern number rhombus

#include
using namespace std;
int main()
{
int i,j,k=0,z=0,x=1;
for(i=1;i<=5;i++)
{ i<=3?k++:k–;
for(j=1;j<=5;j++)
{
if(i<=3)
{
if(j>=4-k&&j<=2+k)
{j<=3?z++:z–;
cout<<z;}
else
cout<<" “;
}
else
if(j>=4-k&&j<=2+k)
{j<=3?x++:x–;
cout<<x;}
else
cout<<” ";

	}
	cout<<endl;
}
return 0;

}

it is not generalized for all n because it is containing one error in last row (it is basically for 5 rows) ,it is not printing same as in upper triangle . if any one could correct this please do it . i m not getting this .i will generalize it after just correcting this error.