# 2975. 排序

$\LaTeX$有错误

### include

using namespace std;
int T,n;
struct num
{
int v;
};
set S;

bool operator<(const num& lhs,const num& rhs)
{
if(lhs.v%10!=rhs.v%10) return lhs.v%10<rhs.v%10;
else return lhs.v<rhs.v;
}

int main()
{
cin>>T;
for(int step=0;step>n;
S.clear();
for(int i=1;i<=n;i++)
{
int xx;cin>>xx;
S.insert((num){xx});
}

int ff=1;
printf("case #%d:\n",step);
set<num>::iterator iter=S.begin();
while(iter!=S.end())
{
if(ff) ff=0; else cout<<' ';
cout<<(*iter).v;
++iter;
}
cout<<endl;


}
return 0;
}

### include

using namespace std;

struct number{
int num;
int num_low;
};

bool cmp(number a, number b){
if(a.num_low == b.num_low){
return a.num < b.num;
}
return a.num_low < b.num_low;
}

int main()
{
int t;
cin >> t;
int i;
for(i = 0; i < t; i++){
int n;
cin >> n;
int j;
number a[n];
for(j = 0; j < n; j++){
cin >> a[j].num;
a[j].num_low = a[j].num % 10;
}
sort(a, a + n, cmp);
cout << “case #” << i << “:” << endl;
cout << a[0].num;
for(j = 1; j < n; j++){
if(a[j].num != a[j-1].num){
cout << ” ” << a[j].num;
}
}
cout << endl;
}
return 0;
}