C# Console �rnekleri � Ok ��areti Olu�turma
Kullan�c�n�n girdi�i geni�lik de�erine g�re kum saati olu�turan program.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | Console.WriteLine("Ka� basamakl� ok yapmak istiyorsunuz");
int n = int.Parse(Console.ReadLine());
Console.WriteLine("{0}{1}{0}",
new string('.', ((n * 2 - 1) - n) / 2),
new string('#', n));
for (int i = 0; i < n - 2; i++)
{
Console.WriteLine("{0}{1}{2}{1}{0}",
new string('.', n / 2),
new string('#', 1),
new string('.', n - 2));
}
Console.WriteLine("{0}{1}{0}",
new string('#', n / 2 + 1),
new string('.', ((n * 2 - 1) - 2 * (n / 2 + 1))));
for (int i = 0; i < n - 2; i++)
{
Console.WriteLine("{0}{1}{2}{1}{0}",
new string('.', i + 1),
new string('#', 1),
new string('.', ((n * 2 - 1) - 4 - (i*2))));
}
Console.WriteLine("{0}{1}{0}",
new string('.',n-1),
new string('#', 1));
Console.ReadKey();
|
|
Yorum Gönder