using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace OverloadingConstructor
{
class Program
{
static void Main(string[] args)
{
int num = 10,x;
StringBuilder s = new StringBuilder();
List<string> list = new List<string>();
for (int i = 1, c = num; i <= num; i++,c--)
{
x = c;
for (int j = 1; j <= i; j++)
{
while (x >= 1)
{
Console.Write(" ");
s.Append(" ");
x--;
}
Console.Write("* ");
s.Append("* ");
}
if(i!=num)
list.Add(s.ToString());
s.Length = 0;
Console.WriteLine();
}
foreach (string stringfinal in list.OrderByDescending(x1=>x1.Length))
{
Console.WriteLine(stringfinal);
}
Console.ReadLine();
}
}
}
Trick 2
using System;
using System.Collections.Generic;
namespace StarUpDown
{
class Program
{
static void Main(string[] args)
{
List<string> listStr = new List<string>();
int x = 10;
for (int i = 1; i <= x; i++)
{
string s = "";
int count = x - i;
for (int j = 1; j <=i; j++)
{
while (count > 0)
{
Console.Write(" ");
count--;
s +=" ";
}
Console.Write("* ");
s += "* ";
}
if (i != x)
listStr.Add(s);
Console.WriteLine();
}
listStr.Reverse();
foreach (var item in listStr)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace OverloadingConstructor
{
class Program
{
static void Main(string[] args)
{
int num = 10,x;
StringBuilder s = new StringBuilder();
List<string> list = new List<string>();
for (int i = 1, c = num; i <= num; i++,c--)
{
x = c;
for (int j = 1; j <= i; j++)
{
while (x >= 1)
{
Console.Write(" ");
s.Append(" ");
x--;
}
Console.Write("* ");
s.Append("* ");
}
if(i!=num)
list.Add(s.ToString());
s.Length = 0;
Console.WriteLine();
}
foreach (string stringfinal in list.OrderByDescending(x1=>x1.Length))
{
Console.WriteLine(stringfinal);
}
Console.ReadLine();
}
}
}
Trick 2
using System;
using System.Collections.Generic;
namespace StarUpDown
{
class Program
{
static void Main(string[] args)
{
List<string> listStr = new List<string>();
int x = 10;
for (int i = 1; i <= x; i++)
{
string s = "";
int count = x - i;
for (int j = 1; j <=i; j++)
{
while (count > 0)
{
Console.Write(" ");
count--;
s +=" ";
}
Console.Write("* ");
s += "* ";
}
if (i != x)
listStr.Add(s);
Console.WriteLine();
}
listStr.Reverse();
foreach (var item in listStr)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment