백준 BOJ C# [2741] [N찍기]

2020. 1. 10. 20:10백준 알고리즘 단계별/for 문

반응형

백준 BOJ C# [2741] [N 찍기]

 

출제 링크 : https://www.acmicpc.net/problem/2741

 

2741번: N 찍기

자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.

www.acmicpc.net

15552번에서 배운 StringBlider 클래스를 활용했다. 한번 배워두면 요긴하게 쓰일 거 같다.

StringBlider는 사용자로 입력받는 미지수의 string값을 분석할 때 많이 쓰인다고 한다.

string과 stringBlider는 사용하는 방법에 따라 프로그래머가 결정해야 된다.

stringlider가 빠르다고 무조건 쓰이는 건 아님!

 

코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using static System.Console;
using System.Text;
using System.IO;
 
namespace baekjoon
{
    class MainApp
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            StringBuilder allNumers = new StringBuilder();
 
            for (int i = 1; i <= input; i++)
            {
                allNumers.Append(i + "\n");
            }
            WriteLine(allNumers);
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs
반응형