#include "iostream"
void bubblesort(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");
bubblesort(data,number);
printf("\n");
for (i=0;i<number;i++){
printf("%d",data[i]);
}
printf("\n");
system("PAUSE");
return 0;
}
void bubblesort(int data[],int n){
int i,j;
for (i=0;i<n;i++){
for (j=i;j<n;j++){
if (data[j]<data[i]){
int temp=data[j];
data[j]=data[i];
data[i]=temp;
}
}
}
}
沒有留言:
張貼留言