배열 초기화 방식 3가지

suee97·2022년 3월 11일
0
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int a[10];

    // 1. memset
    memset(a, 0, sizeof a);

    // 2. for
    for(int i = 0; i < 10; i++) {
        a[i] = 0;
    }

    // 3. fill
    fill(a, a+10, 0);

    return 0;
}

출처: https://www.youtube.com/watch?v=mBeyFsHqzHg&t=563s&ab_channel=BaaarkingDog

profile
승언

0개의 댓글