1 Star 0 Fork 0

向宇 / 初学之旅:2022大一秋

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
c++ 54数组名做函数参数(选择法排序) 771 Bytes
一键复制 编辑 原始数据 按行查看 历史
#include<iostream>
using namespace std;
int main()
{
void Select_sort(int array[],int n);
int a[10],i;
cout<<"enter the orignal array:"<<endl;
for(i=0;i<10;i++) cin>>a[i];
cout<<endl;
Select_sort(a,10);
cout<<"the sorted array:"<<endl;
for(i=0;i<10;i++) cout<<a[i]<<" ";
cout<<endl;
return 0;
}
void Select_sort(int array[],int n)
{
int i,j,k,t;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
{
if(array[j]<array[k]) k=j;
}
if(k!=i)
{
t=array[k];
array[k]=array[i];
array[i]=t;
}
}
}
C
1
https://gitee.com/X_yugg1/learning-journey.git
git@gitee.com:X_yugg1/learning-journey.git
X_yugg1
learning-journey
初学之旅:2022大一秋
master

搜索帮助