vector, arr
int arr[10000];
vector<int> v;
1. 초기화, 제거
fill(arr, arr + n, 0);
fill(v.begin(), v.end(), 0);
memset(arr, 0, sizeof(arr));
v.clear();
remove(v.begin(), v.begin() + 10, 3);
v.erase(v.begin(), v.begin() + 10);
2. 정렬
sort(arr, arr + n);
sort(v.begin(), v.end());
sort(v.vegin(), v.end(), greator<int>()); // 내림차순
// 사용자 정의
bool compare(int, a, int b) {
return a < b;
}
sort(v.begin(), v.end(), compare);
3. 최대 최소
*max_element(arr, arr + n);
*max_element(v.begin(), v.end());
*min_element(arr, arr + n);
*min_element(v.begin(), v.end());
string, char, int
1. 타입 변환
char ch = '1';
int i = ch - '0';
int i = 3;
char ch = i + '0';
int i = 10010;
string s = to_string(i);
string s = "10010";
int i = stoi(s);
string s = "Hello World";
char *ch = s.c_str();
char ch2[100];
strcpy(ch2, s.c_str());
2. find
string s1;
string s2;
if (s1.find(s2) == string::npos) { cout << "Not Found"; }
else { cout << "Found"; }
while (s1.find(s2) != string::npos) {
size_t pos = s1.find(s2);
s1.erase(pos, s2.size());
}