- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int s[] = {-1,-96,-32,3,52,10};
- int omg;
- cout<<"排序前:";
- for(int i=0;i<=5;i++)
- {
- cout<<s[i]<<" ";
- }
- cout<<endl;
- for(int i=0;i<=4;i++)
- {
- for(int u=i+1;u<=5;u++)
- {
- if(s[i]>s[u])
- {
- omg = s[i];
- s[i]=s[u];
- s[u]=omg;
- }
- }
- }
- cout<<"排序後:";
- for(int i=0;i<=5;i++)
- {
- cout<<s[i]<<" ";
- }
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |