寫一程式將 N 個數字依大到小的順序排列。
輸入:由螢幕輸入一正整數 N 及 N 個的數字
輸出:列出 N 個數字的降冪排序
例子:Sample Input Sample Output
6 68 32 10 5 0 -12
0 -12 10 68 5 32
2007-12-18 14:15:54 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 ➔ 程式設計
例子:
Sample Input
6
0 -12 10 68 5 32
Sample Output
68 32 10 5 0 -12
2007-12-18 14:18:15 · update #1
//Power by Visual Studio 2005
//Download Site: http://www.microsoft.com/taiwan/vstudio/express/
#include
#include
using namespace std;
void sort(int Length, int *Number)
{
int l=Length,*n=Number;
for(int i=0;i
}
int main(int argc, char** argv){
//=====START=====//
int num;
cout<<"Input N: ",cin>>num;
int *p=new int[num];
for(int i=0;i
cout<<"Input "<>p[i];
}
sort(num,p);
for(int i=0;i
cout<<" "<
}
delete [] p;
//=====END=====//
system("PAUSE");
return 0;
}
2007-12-18 17:10:09 · answer #1 · answered by Big_John-tw 7 · 0⤊ 0⤋