选择排序

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
void Choicesort(int *a){
	for(int i=1;i<=5;i++){
		for(int j=i+1;j<=5;j++){
			if(a[i]>a[j])
				swap(a[i],a[j]);
		}
	}
	return ;
}
int main(){
	int a[6]={0,4,5,1,3,7};
	Choicesort(a);
		for(int i=1;i<=5;i++)
			cout<<a[i]<<" ";	
	return 0;
}

  

posted @ 2018-04-25 14:54  松手丶明晃晃  阅读(99)  评论(0编辑  收藏  举报