3일차 줄넘기를 하려면 D키를 입력 해주세요. (2) . 홀수의 숫자 색상 바꾸기

Console Programming/C# Console 2019. 9. 20. 16:30
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax06
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("줄넘기를 하려면 D 키를 입력 해주세요.");
            ConsoleKeyInfo info = Console.ReadKey();
            bool condition = info.KeyChar == 'd';
            
            if (condition)
            {
                Console.Write("몇회 줄넘기를 할건가요? ");
                int count = Int32.Parse(Console.ReadLine());
 
                Console.Clear();
 
                for (int i = 1; i < count+1; i++)
                {
                    Console.Write("줄넘기를 ");
                    if (i % 2 == 1)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(i);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write(i);
                    }
 
                    Console.WriteLine("회 했습니다.");
                }
                
            }
            else
            {
                Console.WriteLine("줄넘기를 하지 못했습니다.");
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

: