LATEST
PRINT A PALINDROME NUMBER PYRAMID AS SHOWN BELOW USING C#
INPUT :
5
OUTPUT:
PRINT A PALINDROME NUMBER PYRAMID AS SHOWN BELOW 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;
int reversepalindrome;
for(int i=1;i<=n;i++)
{
reversepalindrome = i-1;
for(int j=1;j<=dummy;j++)
{
if(j<=i)
{
Console.Write(j);
}
else
{
while(reversepalindrome!=0)
{
Console.Write(reversepalindrome);
reversepalindrome--;
}
}
}
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;
int reversepalindrome;
for(int i=1;i<=n;i++)
{
reversepalindrome = i-1;
for(int j=1;j<=dummy;j++)
{
if(j<=i)
{
Console.Write(j);
}
else
{
while(reversepalindrome!=0)
{
Console.Write(reversepalindrome);
reversepalindrome--;
}
}
}
dummy = dummy + 2;
Console.WriteLine();
}
}
}
INPUT :
5
OUTPUT:
Comments
Post a Comment