<commit_before>---
layout: post
title:  "Vector :: 2차원 동적 할당"
date:   2017-10-07
excerpt: "Vector 사용법"
cate : "algorithm"
tag:
- Key Point
---


## Code
{% highlight cpp %}

#include <iostream>
#include <vector>
using namespace std;

int n,m;
vector<vector<int>> v;

int main(){
    int row = 5;
    int col = 3;
    
    v.assign(row, vector<int>(col, 7));
    
    for (int i=0; i<row; i++) {
        for (int j=0; j<col; j++) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

{% endhighlight %}

---
## Output

{% highlight cpp %}

7 7 7 
7 7 7 
7 7 7 
7 7 7 
7 7 7 
Program ended with exit code: 0

{% endhighlight %}


---
## Feed Back 
* <commit_msg>Edit Vector :: 2차원 동적 할당 Post<commit_after>---
layout: post
title:  "Vector :: 2차원 동적 할당"
date:   2017-10-07
excerpt: "Vector 사용법"
cate : "algorithm"
tag:
- Key Point
---

## Review
Vector를 사용하여 2차원 배열을 구현하는 법을 알아보자.

사용법은 간단하다.

2차원이니까  `< vector<vector<int>>  v >` 로 선언을 해주고

`< v.assign(row, vector<int>(col, 7)) >` 할당을 해주면 된다

+ 환경에 따라서 `<vector<vector<int>> v`로 선언을 하면 '<int>>>'를 Shift 연산자로 해석하여
에러가 날 경우가 있으니 `<vector<vector < int > > v` 확실하게 띄어쓰기를 하도록 하자.


---

## Code
{% highlight cpp %}

#include <iostream>
#include <vector>
using namespace std;

int n,m;
vector<vector<int>> v;

int main(){
    int row = 5;
    int col = 3;
    
    v.assign(row, vector<int>(col, 7));
    
    for (int i=0; i<row; i++) {
        for (int j=0; j<col; j++) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

{% endhighlight %}

---
## Output

{% highlight cpp %}

7 7 7 
7 7 7 
7 7 7 
7 7 7 
7 7 7 
Program ended with exit code: 0

{% endhighlight %}



{'fraction_non_alphanumeric': 0.1724748966331955, 'fraction_numerical': 0.03898405197873597, 'mean_word_length': 2.2829457364341086, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5419548', 'n_tokens_mistral': 847, 'n_tokens_neox': 863, 'n_words': 220}