One of my friend asked me to do a homework 4 him, ie to display alphabets in a piramid mode like
I ve made a console application with the following codes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgramContest
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.printFn();
}
private void printFn()
{
string[] ar = new string[] {"A","B","C","D","E","F" };
int len = ar.Length - 1;
while (!string.IsNullOrEmpty(ar[0]))
{
foreach (string s in ar)
{
Console.Write(s != string.Empty ? s : " ");
}
for (int i = ar.Length - 2; i >= 0; i--)
{
Console.Write(ar[i] != string.Empty ? ar[i] : " ");
}
Console.Write(Environment.NewLine);
ar[len] = string.Empty;
len--;
}
Console.Write(Environment.NewLine);
Console.Write(Environment.NewLine);
Console.WriteLine("press any key to exit");
ConsoleKeyInfo k= Console.ReadKey();
if (k.ToString()!=string.Empty)
{
Environment.Exit(0);
}
}
}
}
I ve made a console application with the following codes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgramContest
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.printFn();
}
private void printFn()
{
string[] ar = new string[] {"A","B","C","D","E","F" };
int len = ar.Length - 1;
while (!string.IsNullOrEmpty(ar[0]))
{
foreach (string s in ar)
{
Console.Write(s != string.Empty ? s : " ");
}
for (int i = ar.Length - 2; i >= 0; i--)
{
Console.Write(ar[i] != string.Empty ? ar[i] : " ");
}
Console.Write(Environment.NewLine);
ar[len] = string.Empty;
len--;
}
Console.Write(Environment.NewLine);
Console.Write(Environment.NewLine);
Console.WriteLine("press any key to exit");
ConsoleKeyInfo k= Console.ReadKey();
if (k.ToString()!=string.Empty)
{
Environment.Exit(0);
}
}
}
}
Usually the blog you posted is very useful to us thanks for posting this blog.
ReplyDeletePlease Click Here For More Information About Any Course or Training Institute all over the world
Spark and Scala Training in Houston
https://www.calfre.com/USA/Texas/Houston/Spark-and-Scala-Training/listing