返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int y;
  7.     int n[]={12,57,-6,-32,0,23};
  8.     cout<<"排序前: ";
  9.     for(int i=0; i<6; i++)
  10.         cout<<n[i]<<" ";
  11.     cout<<endl<<"排序後: ";
  12.     for(int i=0; i<5; i++)
  13.     {
  14.          for(int j=0; j<6; j++)
  15.          {
  16.               if(n[j]>n[i])
  17.               {
  18.                   y=n[i];
  19.                   n[i]=n[j];
  20.                   n[j]=y;
  21.               }
  22.          }
  23.     }
  24.     for(int i=0; i<6; i++)
  25.         cout<<n[i]<<" ";
  26.     cout<<endl;
  27.     system("pause");
  28.     return 0;   
  29. }
複製代碼

TOP

返回列表