精華區beta NTUBIME101HW 關於我們 聯絡資訊
#include <iostream> using namespace std; void ary( ); int s[15]={3,8,10,30,2,16,27,13,22,17,42,33,38,29,14}; int main () { for(int i=0;i<15;i++) cout<<s[i]<<" "; cout<<endl; ary( ); for(int i=0;i<15;i++) cout<<s[i]<<" "; system("PAUSE"); return 0; } void ary( ) { int x; for(int i=0;i<15;i++) for(int j=0;j<i;j++) if(s[i]<s[j]) { x=s[i]; s[i]=s[j]; s[j]=x; } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.241.88 ※ 編輯: vincent79715 來自: 140.112.241.88 (12/08 00:50)