留个点赞和关注再走吧!
#include<bits/stdc++.h>
using namespace std;
struct node{
long long dec;
long long otc;
int smal;
}a[200010];
bool cmp(node x,node y)
{
if(x.smal==y.smal&&x.otc<y.otc)
return true;
return x.smal>y.smal;
//if(x.smal>y.smal)
//return true;
//return x.otc<y.otc;
}
int main()
{
int n;cin>>n;
for(int i=0;i<n;i++)
{
int d[100],cnt=0;
int minx=0x3f3f3f3f;
long long ans=0;
cin>>a[i].dec;
int t=a[i].dec;
while(t)
{
d[cnt++]=t%8;
t/=8;
}
for(int j=cnt-1;j>=0;j--)
{
ans=ans*10+d[j];
}
a[i].otc=ans;
a[i].smal=d[0];
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++)
cout<<a[i].otc<<" ";
return 0;
}