以下程序调用函数 用选择法对数组中的值按降序排序 请完成程序。 #include<iostream> using
已帮助 人
以下程序调用函数,用选择法对数组中的值按降序排序,请完成程序。 #include<iostream> using namespace std; void sortd(,int n) { int i, j, p, t; for(i=0; i<n-1; i++) { ; for(; ; j++) if(a[j]>a[p] ) p=j; if(p!=i) { t=a[i]; a[i]=a[p]; a[p]=t; } } } void main() { int a[10]; for(int i=0; i<10; i++) cin>>a[i]; sortd(a, 10); for(i=0; i<10; i++) cout<<a[i]<<"t"; cout<<"n"; }

回答
共1条回复-
B
