怎么不对呢 #include<iostream> #include<iomanip> using namespace std; int findmaxpos(int arr[],int n) { int max=arr[0]; int pos=0; for(int i=1; i<n; i++) { if(arr[i]>max) { max=arr[n]; pos=i; } } return pos; } void selectionSort(int arr[],int n) { while(n>1) { int pos=findmaxpos(arr,n); int temp=arr[n-1]; arr[n-1]=arr[pos]; arr[pos]=temp; n--; } } int main() { int a[10]; for(int i=0; i<10; i++) cin>>a[i]; selectionSort(a,10); for(int i=0; i<10; i++) cout<<a[i]<<endl; }
C二级辅导-公约公倍 (C语言代码)浏览:1508 |
简单的a+b (C语言代码)浏览:537 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:595 |
人见人爱A+B (C语言代码)浏览:626 |
最小公倍数 (C语言代码)浏览:863 |
三角形 (C语言代码)浏览:904 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |
回文数字 (C语言代码)浏览:2509 |
数组与指针的问题浏览:716 |
C语言训练-亲密数 (C语言描述,反正怎么都能对)浏览:2157 |