[백준] C# : 별 찍기 - 1 (2438번)

ssu_hyun·2022년 7월 27일
0

Data Structure & Algorithm

목록 보기
40/67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Baekjoon
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i=0; i < n; i++)
            {
            	// StringBuilder 객체 생성
                StringBuilder builder = new StringBuilder();
                for (int j = 0; j <= i; j++)
                {
                    builder.Append("*");
                }
                Console.WriteLine(builder);
            }
        }
    }
}
  • StringBuilder sb = new StringBuilder();
    • 변경가능한 문자열을 나타내는데 사용하는 클래스
    • 참조 값이 변경되지 않고 힙 메모리에서 값 삽입, 추가, 제거
    • System.Text 네임스페이스 객체
    • 메서드
      • Append()
      • Insert()
      • Remove()
      • Replace()

0개의 댓글