Program code (in c++)
#include<iostream>
using namespace std;
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
for(int i=1;i<=5;i++)
{
for(int p=1;p<=5-i;p++)
{
cout<<" ";
}
int n=1;
int k=i;
do{
if(n<=i)
{
cout<<a[k];
k++;
}
else{
k--;
cout<<a[k-1];
}
n++;
}while(n<=(2*i-1));
cout<<"\n";
}
return 0;
}