57 (2).PNG

#include<iostream.h>
#include<conio.h>
void main()
{
                int i,j,k,n;
                clrscr();
                cout<<"Enter The Length of Pattern :- ";
                cin>>n;
                for(i=1;i<=n;i++)
                                {
                                cout<<endl;
                                for(k=1;k<=i;k++)
                                                {
                                                cout<<i<<" ";
                                                if(n>=10)
                                                                {
                                                                if(i>9)
                                                                                {}
                                                                else
                                                                                {
                                                                                cout<<" ";
                                                                                }
                                                                }
                                                }
                                for(j=1;j<=n-i;j++)
                                                {
                                                if(j==n-i)
                                                                {
                                                                if(n>=10)
                                                                                {
                                                                                cout<<"   ";
                                                                                }
                                                                else
                                                                                {
                                                                                cout<<"  ";
                                                                                }
                                                                }
                                                else
                                                                {
                                                                if(n>=10)
                                                                                {
                                                                                cout<<"      ";
                                                                                }
                                                                else
                                                                                {
                                                                                cout<<"    ";
                                                                                }
                                                                }
                                                }
                                for(k=1;k<=i;k++)
                                                {
                                                if(k==n)
                                                                {}
                                                else
                                                                {
                                                                cout<<i<<" ";
                                                                if(n>=10)
                                                                                {
                                                                                if(i>9)
                                                                                                {}
                                                                                else
                                                                                                {
                                                                                                cout<<" ";
                                                                                                }
                                                                                }
                                                                }
                                                }
                                }
                getch();
}

57

Advertisements