计数排序
#include <iostream> #include "cstring" #include "string" using namespace std; const int L=10000; int main(){ int i,n,a[L],num[L+1],Size; int T; cin>>T; while (T--) { cin>>n; for(i=0;i<n;i++) cin>>a[i]; Size=0; memset(num, 0, sizeof(num)); for(i=0;i<n;i++){ num[a[i]]++; } int j=0; for(i=0;i<L+1;i++){ while(num[i]>0){ //if为去冲,while为不去重 num[i]--; a[j]=i; j++; } } for(i=0;i<j;i++){ cout<<a[i]<<" "; } cout<<endl; } return 0; }