2일차 ***별찍기2*** 의 코드 수정

Console Programming/C# Console 2019. 9. 21. 05:36
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax01
{
    class Program
    {
        static void Main(string[] args)
        {
 
            Console.WriteLine("*** 별찍기2 ***");
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (i + j > 3)
                    {
                        Console.Write("*");
                    }
                        
                    else
                        Console.Write(" ");
 
                }
                Console.WriteLine();
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

친구의 도움으로 2차원 배열에서는 for문을 두개만 사용해도 충분히 표현할 수 있다는 것을 알았고,

그 코드를 다시 집에 와서 작성한다.

 

(0,0) (0,1) (0,2) (0,3)

(0,4)*

(1,0) (1,1) (1,2) (1,3)* (1,4)*
(2,0) (2,1) (2,2)* (2,3)* (2,4)*
(3,0) (3,1)* (3,2)* (3,3)* (3,4)*

: