1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | bool comparator(int a, int b){ return a>b; } int main(){ vector<int> v = {5,1,4,8,7,4,9,2}; sort(v.begin(),v.end(),comparator); for(int i : v){ cout << i << " "; } cout << endl; // 5 4 3 2 1 string s = "hello world"; sort(begin(s),end(s)); cout << s; while(1){} return 0; } | cs |
'2019 > c++' 카테고리의 다른 글
| File I/O (0) | 2018.03.30 |
|---|---|
| STL Queues (0) | 2018.03.28 |
| maps STL (0) | 2018.03.25 |
| variables and memory, declaration (0) | 2018.03.24 |
| list inserts and deletes (0) | 2018.03.24 |