- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int y;
- int n[]={12,57,-6,-32,0,23};
- cout<<"排序前: ";
- for(int i=0; i<6; i++)
- cout<<n[i]<<" ";
- cout<<endl<<"排序後: ";
- for(int i=0; i<5; i++)
- {
- for(int j=0; j<6; j++)
- {
- if(n[j]>n[i])
- {
- y=n[i];
- n[i]=n[j];
- n[j]=y;
- }
- }
- }
- for(int i=0; i<6; i++)
- cout<<n[i]<<" ";
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |