"C++ 맵"의 두 판 사이의 차이

5번째 줄: 5번째 줄:
#include <iostream>
#include <iostream>
#include <map>
#include <map>
using namespace std;
using namespace std;


14번째 줄: 13번째 줄:
      
      
     for(auto it=m.cbegin(); it!=m.cend(); it++) {
     for(auto it=m.cbegin(); it!=m.cend(); it++) {
         cout << it->first << ": " << it->second << endl;
         cout << "key: " << it->first << " => ";
        cout << "value: " << it->second << endl;
     }
     }
}
}

2023년 9월 9일 (토) 13:39 판

1 개요

C++ 맵
#include <iostream>
#include <map>
using namespace std;

int main() {
    map<string, int> m;
    m["x"] = 40;
    m["y"] = -74;
    
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << "key: " << it->first << " => ";
        cout << "value: " << it->second << endl;
    }
}

2 멤버 함수

3 같이 보기

4 참고

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