想用sort()函数需要加上   #include <algorethm>这个头文件;

sort(begin,end)表示一个范围;

如例子:


#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
int a[10]={1,8,7,6,9,4,3,5,2,10,},i;
for(i=0;i<10;i++)
cout<<a[i]<<endl;
sort(a,a+10);
for(i=0;i<10;i++)
cout<<a[i]<<endl;
return 0;
}

 

 

sort()的用法

 

相关文章:

  • 2021-11-21
  • 2021-11-21
  • 2021-08-08
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-02-08
  • 2021-06-15
  • 2022-01-20
  • 2021-11-21
相关资源
相似解决方案