본문 바로가기
01.Bit 단기/C++

45_STL Sort 함수

by chojju 2018. 5. 9.
반응형

#include <iostream>
#include <algorithm> //STL 알고리즘 함수
using namespace std;
#include <time.h>

int main()
{
 srand((unsigned int)time(NULL));
 int arr[10];
 for (int i = 0; i < 10; i++)
  arr[i] = rand();

 cout << "정렬 전" << endl;
 for (int i = 0; i < 10; i++)
  cout << arr[i] << "\t";
 cout << endl;

 sort(arr, arr + 10); //<================

 cout << "정렬 후" << endl;
 for (int i = 0; i < 10; i++)
  cout << arr[i] << "\t";
 cout << endl;
 
 return 0;
}

반응형

'01.Bit 단기 > C++' 카테고리의 다른 글

47_char 저장 컨테이너  (0) 2018.05.09
46_int 저장 컨테이너  (0) 2018.05.09
44_STL find 함수  (0) 2018.05.09
43_find 템플릿 함수 구현  (0) 2018.05.09
42_전문화템플릿  (0) 2018.05.08

댓글