标签:int 输入 pre std 整数 ace span main namespace
3 1 2 5 -1 5 3 1 2 3 4 5 0 0
5 5 4 3
#include<iostream> #include<algorithm> using namespace std; int main(){ int i,n,m; int a[100001]; while(cin>>n>>m){ if(n==0 && m==0) break; for(i=0;i<n;i++){ cin>>a[i]; } sort(a,a+n); bool first=true; if(n<=m){ for(i=n-1;i>=0;i--){ if(first) { first=false; cout<<a[i]; } else cout<<" "<<a[i]; } cout<<endl; } else { for(i=n-1;m>0;m--){ if(first){ first=false; cout<<a[i]; } else cout<<" "<<a[i]; i--; } cout<<endl; } } return 0; }
标签:int 输入 pre std 整数 ace span main namespace
原文地址:https://www.cnblogs.com/bernieloveslife/p/9736577.html