作业帮 > 综合 > 作业

c语言——选择排序  给定一个长度为n的数列,将这个数列按从小到大的顺序排列.1

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/22 20:01:51
c语言——选择排序
  给定一个长度为n的数列,将这个数列按从小到大的顺序排列.1
递归版
#include
#include
#define arrSize 1000
void RecurSelectSort(int a[],int n,int i);
main()
{
int a[arrSize],i,n;
\x09 printf("Please input the number of integers:"); /* 打印提示信息 */
scanf("%d",&n); /* 读取字符串长度 */
\x09 printf("Please input the integers:"); /* 打印提示信息 */
\x09 /* 读取数组元素 */
for(i=0;i2){
b=a[n-1];
a[n-1]=a[n-2];
a[n-2]=b;
}
\x09\x09RecurSelectSort(a,n-1,i);
\x09\x09i=0;
\x09}
}