返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int tmp=0;
  7.     int a[6]={987,78,978,569,87,38};
  8.     cout<<"排序前: ";
  9.     for(int i=0; i<6; i++)
  10.         cout<<a[i]<<" ";
  11.     for(int i=0; i<5; i++)
  12.     {
  13.         for(int j=i+1; j<6; j++)
  14.         {
  15.             if(a[j]<a[i])
  16.             {
  17.                 tmp=a[i];
  18.                 a[i]=a[j];
  19.                 a[j]=tmp;
  20.             }
  21.         }
  22.     }
  23.     cout<<endl;
  24.     cout<<"排序後: ";
  25.     for(int i=0; i<6; i++)
  26.         cout<<a[i]<<" ";
  27.     cout<<endl;
  28.     system("pause");
  29.     return 0;   
  30. }
複製代碼
寶寶心裡苦,但寶寶不說。

TOP

返回列表