#include<iostream>
using namespace std
;
void bubbleSort(int *arr
,int len
){
int temp
;
for(int i
= 0;i
<len
-1;i
++)
for(int j
= 0;j
<len
-i
-1;j
++){
if (arr
[j
]>arr
[j
+1]){
temp
= arr
[j
];
arr
[j
] = arr
[j
+1];
arr
[j
+1] = temp
;
}
}
}
void printArr(int *arr
,int len
){
for(int i
= 0;i
<len
-1;i
++)
cout
<< arr
[i
];
}
int main(){
int arr
[] = {4,2,8,0,5,7,1,3,9};
int len
= sizeof(arr
)/sizeof(arr
[0]);
bubbleSort(arr
,len
);
printArr(arr
,len
);
system("pause");
}
转载请注明原文地址:https://tech.qufami.com/read-10397.html