- #include<iostream>
- using namespace std;
- int main(){
- int tmp;
- 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=i+1; j<6; j++){
- if(n[i]<n[j]){
- tmp=n[j];
- n[j]=n[i];
- n[i]=tmp;
- }
- }
- }
-
- cout<<"排序後: ";
- for(int i=0; i<6; i++)
- {
- cout<<n[i]<<" ";
- }
- cout<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |