题解 | #C++选择排序#
C++选择排序
http://www.nowcoder.com/practice/3b6175426e704c0b9461628b2278631b
using namespace std;
int main() {
int arr[6] = { 0 };
int len = sizeof(arr) / sizeof(int);
for (int i = 0; i < len; i++) {
cin >> arr[i];
}
int i,j,k;
int t;
for(i=0;i<len;i++){
for(j=i+1;j<len;j++){
if(arr[i]>arr[j]){
t=arr[i];
arr[i]=arr[j];
arr[j]=t;
}
}
}
for(k=0;k<len-1;k++){
printf("%d ",arr[k]);
}
printf("%d\n",arr[len-1]);
// write your code here......
return 0;
}