using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class Pyramid
{
static void Main(string[] args)
{
int i, j, k, num;
Console.Write("Please enter the number of layers: ");
String strNUM = Console.ReadLine();
num = int.Parse(strNUM);
for (i = 1; i <= num; i++)
{
for (j = 1; j <= 2 * (num - i) + i; j++)
Console.Write(" ");
for (k = 1; k <= 2 * i - 1; k++)
Console.Write("o");
Console.WriteLine();
}
Console.ReadLine();
}
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUTPUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please enter the number of layers: 6
o
ooo
ooooo
ooooooo
ooooooooo
ooooooooooo
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class Pyramid
{
static void Main(string[] args)
{
int i, j, k, num;
Console.Write("Please enter the number of layers: ");
String strNUM = Console.ReadLine();
num = int.Parse(strNUM);
for (i = 1; i <= num; i++)
{
for (j = 1; j <= 2 * (num - i) + i; j++)
Console.Write(" ");
for (k = 1; k <= 2 * i - 1; k++)
Console.Write("o");
Console.WriteLine();
}
Console.ReadLine();
}
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUTPUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please enter the number of layers: 6
o
ooo
ooooo
ooooooo
ooooooooo
ooooooooooo
No comments:
Post a Comment