PRINT ALPHABET PALINDROMIC PYRAMID USING C#
using System;
public class Test
{
public static void Main()
{
var number = Console.ReadLine();
int n = Convert.ToInt32(number);
Pattern print = new Pattern();
print.PrintPalindromePattern(n);
}
}
public class Pattern
{
public void PrintPalindromePattern(int n)
{
int dummy = 1;
char letter = 'A';
int reversepalindrome;
char letteraftereachIteration ='A';
char reverseletter ='A';
for(int i=1;i<=n;i++)
{
reversepalindrome = i-1;
for(int j=1;j<=dummy;j++)
{
if(j<=i)
{
Console.Write(letter++);
}
else
{
while(reversepalindrome!=0)
{
Console.Write(reverseletter);
reversepalindrome--;
reverseletter--;
}
}
}
if(i!=1)
{
letteraftereachIteration ++;
}
reverseletter =letteraftereachIteration;
letter='A';
dummy = dummy + 2;
Console.WriteLine();
}
}
}
public class Test
{
public static void Main()
{
var number = Console.ReadLine();
int n = Convert.ToInt32(number);
Pattern print = new Pattern();
print.PrintPalindromePattern(n);
}
}
public class Pattern
{
public void PrintPalindromePattern(int n)
{
int dummy = 1;
char letter = 'A';
int reversepalindrome;
char letteraftereachIteration ='A';
char reverseletter ='A';
for(int i=1;i<=n;i++)
{
reversepalindrome = i-1;
for(int j=1;j<=dummy;j++)
{
if(j<=i)
{
Console.Write(letter++);
}
else
{
while(reversepalindrome!=0)
{
Console.Write(reverseletter);
reversepalindrome--;
reverseletter--;
}
}
}
if(i!=1)
{
letteraftereachIteration ++;
}
reverseletter =letteraftereachIteration;
letter='A';
dummy = dummy + 2;
Console.WriteLine();
}
}
}
OUTPUT
Comments
Post a Comment