"C++ 벡터 벡터"의 두 판 사이의 차이

 
10번째 줄: 10번째 줄:
int main() {
int main() {
     vector<vector<int>> v = {{1,2},{3,4},{5,6}};
     vector<vector<int>> v = {{1,2},{3,4},{5,6}};
     for(vector<int> row: v) {
     for(const vector<int>& row: v) {
         for(int cell: row) {
         for(const int& cell: row) {
             cout << cell << ' ';
             cout << cell << ' ';
         }
         }

2024년 1월 7일 (일) 01:05 기준 최신판

1 개요[ | ]

C++ 벡터 벡터
C++ 2차원 벡터
#include <iostream>
#include <vector>
using namespace std;

int main() {
    vector<vector<int>> v = {{1,2},{3,4},{5,6}};
    for(const vector<int>& row: v) {
        for(const int& cell: row) {
            cout << cell << ' ';
        }
        cout << '\n';
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}