C# Console Örnekleri – Ok İşareti Oluşturma

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();



0 Comments


EmoticonEmoticon