請問陣列~由大至小排序
{4,5,3,9,8,7,6,1,2,22}
2007-11-15 13:32:46 · 2 個解答 · 發問者 ? 1 in 電腦與網際網路 ➔ 程式設計
int i,j,t;
int a[10]={4,5,3,9,8,7,6,1,2,22};
for (i=0;i<=10 ; i++)
for (j=0;j<=10 ; j++)
if (a[i]
2007-11-15 19:02:37 · update #1
#include
#include
main(){
int A[10]={4,5,3,9,8,7,6,1,2,22},i,j,c;
for(i=0;i<=9;i++)
{printf("%d ",A[i]);
} printf("\n");
for(i=0;i<=9;i++){
for(j=i+1;j<=9;j++){
if(A[i]<=A[j]){
c=A[i];
A[i]=A[j];
A[j]=c;
}
}
printf("%d ",A[i]);
}
system("pause");
}
2007-11-15 22:00:19 · answer #1 · answered by seika 3 · 0⤊ 0⤋
#include
#include
void sort(int Len, int *Number){
int l=Len,*n=Number,i,j,tmp;
for(i=0;i
}
int main(int argc, char* argv[]){
//=====START=====//
int n[]={4,5,3,9,8,7,6,1,2,22},i,l=sizeof(n)/sizeof(n[0]);
sort(l,n);
for(i=0;i
}
printf("\n");
//=====END=====//
system("PAUSE");
return 0;
}
2007-11-15 15:33:39 · answer #2 · answered by Big_John-tw 7 · 0⤊ 0⤋