728x90
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
bool comp(string s1, string s2){
return s1 < s2;
}
int main(){
string arr[5] = {"abc", "aa", "abcd", "aza", "bcda"};
sort(arr, arr+5, comp);
for(int i=0;i<5;++i){
cout << arr[i] << endl;
}
return 0;
}
728x90
'알고리즘 > 개념' 카테고리의 다른 글
알고리즘의 시간복잡도 (0) | 2020.09.16 |
---|---|
[C++] pair (0) | 2020.09.04 |
C++ 알고리즘 실행시간 줄이기 (0) | 2020.08.22 |
문자열 총정리 <C++>: char, string, #include <cstring>, #include <string>, getline, 문자열 (0) | 2020.07.12 |
큐(queue), 스택(stack) 명령어 정리와 연습문제 (0) | 2020.05.17 |
댓글