选择排序(调用函数)

547.#include<iostream>
548.using namespace std;
549.int main()
550.{void select_sort(int array[],int n);
551.int a[10],i;
552.cout<<"请输入五个数:"<<endl;
553.for(i=0;i<5;i++)
554.cin>>a[i];
555.cout<<endl;
556.select_sort(a,10);
557.cout<<"输出五个数:"<<endl;
558.for(i=0;i<5;i++)
559.cout<<a[i]<<" ";
560.cout<<endl;
561.return 0;
562.}
563.void  select_sort(int array[],int n)
564.{int i,j,k,t;
565.for(i=0;i<5;i++)
566.{k=i;
 567.for(j=1+i;j<n;j++)
568.  if(array[j]<array[k])
569. k=j;
570.t=array[k];array[k]=array[i];array[i]=t;
571.}
572.}

你可能感兴趣的:(选择排序(调用函数))