c++

stl vector map

풀스택 개발자 2021. 3. 9. 20:24

 

#include <iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;
int main()
{
	vector<vector<string>> a = { {"yellowhat", "headgear" }, { "bluesunglasses", "eyewear" }, { "green_turban", "headgear" }};//2차원 벡터 
	map<string, int> arr;

	arr["sta"]++;//key sta value +1;
	arr["sta"]++;//key sta value +1;

	cout << a[0][0] << endl;//a벡터의 [0][0] 즉 yellowhat
	cout << a[0][1] << endl;//a벡터의 [0][1] 즉 headgear

	cout << arr.find("sta")->second;//key sta 의 value값 가져오기


	//cout << a[0][0];
	/*for (int i=0;i<a.size;i++)
	{
		arr[a[i][1]];
	}*/

}