목차

  1. 환경
  2. 문제
  3. 접근법
  4. Library
  5. Code
  6. 정리
  7. Link

1. 환경

Editor: Microsoft Visual Studio Code
Compiler: C++20

2. 문제

Link1 BOJ2741

3. 접근법

알고리즘 분류

  • 구현

for문의 대표적인 예제이다.

4. Library

bits/stdc++.h - Link2
(GNU C++ Standard Library Header - X)
(GCC Compiler Header - O)

5. Code

#include <bits/stdc++.h>

using namespace std;

int N;

void input();
void func();
void output();

int main(void)
{
    input();
    func();
    output();
}

void input()
{
    cin >> N;
}

void func()
{

}

void output()
{
    for(int i = 1; i <= N; i++)
        cout << i << '\n';
}

6. 정리

나 자신에게만 해당되는 이야기일 수 있지만,
Container를 사용할때 Index가 0부터 시작하여
습관적으로 for문의 변수를 0부터 사용하는데,
이런 작은 습관으로 나중에 큰 낭패를 볼 수 있으니 유의하자.

1. BOJ2741 - N 찍기
https://www.acmicpc.net/problem/2741
2. bits/stdc++.h
https://gcc.gnu.org/onlinedocs/gcc-4.8.0/libstdc++/api/a01541_source.html
3. Cplusplus.com
https://www.cplusplus.com/reference/