关于sort函数
sort用于C++中,将数字从小到大排列。
1 /* 2 Name: sort用法 3 Copyright: Analyst 4 Author: Analyst 5 Date: 27/02/14 22:52 6 Description: dev-cpp 5.5.3 7 */ 8 #include <iostream> 9 #include <algorithm> //sort头文件 10 using namespace std; 11 int main() 12 { 13 int array[10] = {4,2,0,6,8,1,3,5,9,7}; 14 15 sort(array,array+10); //排序 16 for (int i = 0; i < 10; ++i) 17 printf("%d ",array[i]); 18 19 return 0; 20 }
运行结果:
0 1 2 3 4 5 6 7 8 9
--------------------------------
Process exited with return value 0
Press any key to continue . . .