내가 헷갈리는거 정리
1. 문자열 -> string::npos
string s = "abcde";
auto it = s.find('c');
if(it != string::npos){
cout<< s.substr(0,it);
}
2. map -> m.end() ( 키 찾을떄!!)
if(m.find("good")!=m.end()){
cout<<"find";
}else{
cout<<"not found";
}
2_1 map 반복접근 ->
for(auto it : m ) 후에 .first,second
for (auto it : m)
{
cout << it.first << " " << it.second << "\n";
}
m.erase("키값");
3. set
set find도 map과 같음.,
4. vector 복사
4_1. vector 선언
vector<자료구조> v ( vec.size());
copy(vec.begin(),vec.end(),v.begin())
'코테공부' 카테고리의 다른 글
vector , memset 정리 (1) | 2023.09.25 |
---|---|
C++ heap ( 우선순위 큐) (0) | 2023.08.23 |
c++ Priority_queue Compare 정의 (0) | 2022.12.01 |
카카오기출 코딩테스트 공부 c++ (0) | 2022.11.15 |
다익스트라 알고리즘 (0) | 2022.11.04 |