#include "iostream"
void selectionsort(int data[],int n);
void quicksort(int data[],int left,int right);
void heapsort(int data[],int number);
void heap(int data[],int index,int n);
void shellsort(int data[],int n);
void mergesort(int a[],int left,int right);
void merge(int a[],int left,int mid,int right);
void radix(int data[],int n);
int main()
{
int number=9;
int data[]={5,6,4,8,2,3,7,9,1};
int i;
for (i=0;i<number;i++){
printf("%d",data[i]);
}
printf("\n");
selectionsort(data,number);
printf("\n");
for (i=0;i<number;i++){
printf("%d",data[i]);
}
printf("\n");
system("PAUSE");
return 0;
}
void selectionsort(int data[],int n){
int i,j;
int temp;
for (i=0;i<n;i++){
temp=i;
for (j=i+1;j<n;j++){
if (data[temp]>data[j]){
temp=j;
}
}
int flag=data[temp];
data[temp]=data[i];
data[i]=flag;
}
}
沒有留言:
張貼留言