C++ : generate the pyramid of number as


              1
    121
   12321
  1234321
123454321

==================================================


#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
int i,j,k,l;
for(i=1;i<=5;i++)
{
for(l=1;l<=5-i;l++)
{
cout<<" ";
}
for(j=1;j<=i-1;j++)
{
cout<<j;
}
for(k=i;k>=1;k--)
{
cout<<k;
}
cout<<endl;
}
getch();
return(0);

}

No comments:

Post a Comment