标签:eve style spl input ott 输出 opened name alt
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int ans[101]; 6 int n; 7 while(cin>>n&&n) 8 { 9 for(int i=1;i<=n;++i) 10 { 11 cin>>ans[i]; 12 } 13 for(int i=1;i<n;++i) 14 { 15 int k=i; 16 for(int j=i+1;j<=n;++j) 17 { 18 int a=abs(ans[j]),b=abs(ans[k]); 19 if(a>b) k=j; 20 } 21 swap(ans[i],ans[k]); 22 } 23 cout<<ans[1]; 24 for(int i=2;i<=n;++i) 25 cout<<" "<<ans[i]; 26 cout<<endl; 27 } 28 }
下边的没过啊
桶排序:
1 #include<bits/stdc++.h> 2 #define LL long long 3 using namespace std; 4 int ans[101]; 5 bool res[101]; 6 int main() 7 { 8 9 int n; int a; 10 while(cin>>n&&n) 11 { 12 memset(res,0,sizeof(res)); 13 for(int i=1;i<=n;++i) 14 { 15 16 cin>>a; 17 ans[abs(a)]=a; 18 res[abs(a)]=1; 19 } 20 bool r=true; 21 for(int i=100;i>=1;--i) 22 { 23 if(res[i]!=0) {if(r==true)cout<<ans[i];else cout<<" "<<ans[i];r=false;} 24 } 25 cout<<endl; 26 } 27 }
标签:eve style spl input ott 输出 opened name alt
原文地址:https://www.cnblogs.com/Auroras/p/10798552.html