-1

write a program to view a pyramid structure of a input number. pyramid should look like this
if number is 5
then pyramid will be
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by karidoe
0

Hi, I'm not sure that your meaning like this ..........

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace pyramid
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("IN PUT YOUR NUMBER :");
            int myInt = int.Parse(Console.ReadLine());
            for (int iCount1 = 1; iCount1 <= myInt; iCount1++)
            {
                for (int iCount2 = 1; iCount2 <= iCount1; iCount2++)
                {
                    Console.Write(iCount2 + " ");
                }
                for (int iCount3=(iCount1-1);iCount3 >= 1; iCount3--)
                {
                    Console.Write(iCount3 + " ");
                }
                Console.WriteLine("");
            }
        }
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.