#include <iostream>
using namespace std; 
int main() {
 int rows, space, count=0,count1=0,k=0;
 cout <<"Enter the no of rows "<<endl; 
 cin>>rows; 
 for (int i=1;i<=rows;++i)
 {
     for (space=1;space<=rows-i; ++space)
     {
         cout <<"  ";
     }
     while (k != 2*i-1)
     {
         if (count<=rows-1)
         {
         cout <<i+k<<" ";
         ++count;
         }
         else 
         {
             ++count1;
             cout <<i+k-2*count1<<" ";
         }
         ++k; 
     }
     count=count1=k=0;
     cout <<endl; 
 }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: