Program to print number sequence in C++ (3)

/* Program to print sequence

                   1
                  121
                 12321
                1234321
                 12321
                  121
                   1
*/

#include<stdio.h>
#include<iostream>
main()
    {
        int i,j,k,p=4;
        for(i=1;i<=4;i++)
        {
            for(k=1;k<=p;k++)
                std::cout<<" ";
            p--;
            for(j=1;j<=i;j++)
                std::cout<<j;
            for(j=i-1;j>=1;j--)
                std::cout<<j;
            std::cout<<"\n";
        }
        p=2;
        for(i=3;i>=1;i--)
        {
            for(k=1;k<=p;k++)
                std::cout<<" ";
            p++;    
            for(j=1;j<=i;j++)
                std::cout<<j;
            for(j=i-1;j>=1;j--)
                std::cout<<j;
            std::cout<<"\n";
        }
    }    

Top