C++ 简单选择排序
来源:互联网 发布:sql分组累计求和 编辑:程序博客网 时间:2024/05/29 13:55
简单选择排序是一种不稳定的排序算法,复杂度为n^2
#include
using namespace std;
void s_selsort(int a[],int n)
{
int temp,temp2;
for(int i=0;i
{
temp=i;
for(int j=i+1;j
if(a[temp]>a[j])
temp=j;
temp2=a[i];
a[i]=a[temp];
a[temp]=temp2;
}
}
int main()
{
int a[]={2,6,3,4,9,5,3,2,1,9,3};
s_selsort(a,11);
for(int i=0;i<11;i++)
cout<<a[i]<<",";
return 0;
}
#include
using namespace std;
void s_selsort(int a[],int n)
{
int temp,temp2;
for(int i=0;i
{
temp=i;
for(int j=i+1;j
if(a[temp]>a[j])
temp=j;
temp2=a[i];
a[i]=a[temp];
a[temp]=temp2;
}
}
int main()
{
int a[]={2,6,3,4,9,5,3,2,1,9,3};
s_selsort(a,11);
for(int i=0;i<11;i++)
cout<<a[i]<<",";
return 0;
}
0 0
- C++ 简单选择排序
- C 简单选择排序
- c语言简单选择排序
- 简单选择排序(C)
- 简单选择排序(C & Java 实现)
- 简单选择排序(C语言实现)
- 数据结构c语言版之简单选择排序
- 简单选择排序(C/C++实现)
- C语言 简单选择排序算法
- 【算法】简单选择排序C语言实现
- c语言数据结构 简单选择排序
- C 语言-简单选择排序
- 简单选择排序(C语言版本)
- C语言 简单选择排序算法
- 简单选择排序—C—python
- C++——简单选择排序
- 选择排序-简单选择排序
- 【选择排序】简单选择排序
- 分数类中的运算符重载
- 香港特区政府接获8宗港人在越南
- 背包问题
- linux使用技巧及经验
- hdu1358 最小循环节,最大循环次数 KMP
- C++ 简单选择排序
- 21天战拖记——Day14:如何养成一个习惯?(2014-05-17)
- 异常为"当IDENTITY_INSERT设置为OFF时" 的解决
- 概念了解:CGI,FastCGI,PHP-CGI与PHP-FPM
- 大数据博客推荐
- 计算机网络学习 - TCP
- 实现二值图像连通区标记之区域生长法
- hdu1686 最大匹配次数 KMP
- 二五八记牌器