본문 바로가기
알고리즘/개념

문자열 정렬

by 코드 이야기 2020. 8. 11.
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

댓글