#include<stdio.h>
#include<stdlib.h>
void SelectSort(int *a,int n);//预声明要调用的函数
int main(void)
{
int k;
int x[]={,,,,,,,,,};
for(k=;k<;k++)
printf("%d",x[k]);
printf("\n");
SelectSort(x,);
for( k=;k<;k++)
printf("%d",x[k]);
printf("\n");
system("pause"); return ;
} void SelectSort(int *a,int n)//数组元素是指针,数组数量
{
int i,j,t;//整型变量
int min;//最小值,索引号
for(i=;i<n-;i++)//n-1次扫描
{
min=i;//每次扫描前第一个元素(最小)
for(j=i+;j<n;j++)//第二轮扫描找到最小值并交换
{
if(a[j]<a[min])
min=j; }
t=a[i];//临时变量
a[i]=a[min];//
a[min]=t;
} }

选择排序基本思想:每一趟(如第n趟)在后面n-i+1(i=1,2,…,n-1)个待排序元素中选取关键字最小的元素,作为有序子序列的第i个元素,直到第n-1趟做完,待排序元素只剩下一个,就不用再选了。

最新文章

  1. 弹出popwindow 背景变暗
  2. android opengl es代码功能
  3. iOS闪烁效果工具 GlitchLabel
  4. jQuery动画效果实现
  5. 第六篇、CSS属性
  6. paip.gch预编译头不生效的原因以及解决:
  7. codeforces 622E. Ants in Leaves
  8. ie6下margin双倍距的问题
  9. JMeter之Throughput Controller详解(实验)
  10. 最常见的三个排序(冒泡、直接插入、快速)的JS实现
  11. Sql Server的艺术(六) SQL 子查询,创建使用返回多行的子查询,子查询创建视图
  12. 题目1032:ZOJ
  13. 从0开始的Python学习016异常
  14. 「技巧」如何快速安装 Sketch 插件
  15. 使用Autoencoder进行降维
  16. BZOJ.2655.calc(DP/容斥 拉格朗日插值)
  17. 华为5G在印度被禁
  18. WPF 程序在 Windows XP 下报错:The image format is unrecognized.
  19. HDU 4632 Palindrome subsequence(区间DP求回文子序列数)
  20. UVA 10194 (13.08.05)

热门文章

  1. uva10001 Garden of Eden
  2. Xcode 编译的哪些错误
  3. Java 中包装类wrapped type之间以及和primitive type的比较
  4. Maven 常用命令, 备忘
  5. Centos5, 6下更改系统时间和时区
  6. JS给文本框赋值后,在页面后台取不到文本框值的解决方法
  7. python执行linux shell管道输出内容
  8. win7 IIS7.5配置伪静态
  9. JS明确指定函数的接受者
  10. 关于viewpager 里嵌套 listview 同时实现翻页功能的“java.lang.IllegalStateException: The specified child...&quot;异常处理