求改
查看原帖
求改
1394471
HZY1618yzh楼主2024/12/1 17:12
#include<bits/stdc++.h>
using namespace std;
int n,str,c[21][21];
struct s{
    int s,sh;
}b[256];
char a[21][41];
int f(int x){
    if(x<='9'){
        return x-'0';
    }
    return x-'A'+10;
}
char ff(int x){
    if(x<=9){
        return x-10+'A';
    }
    return x+'0';
}
int fff(int c){
    int dis=256,res=-1;
    for(int i=0;i<16; i++){
        int d=c-b[i].sh;
        if(d<0){
            d=-d;
        }
        if(d<dis){
            dis=d;
            res=i;
        }
    }
    return res;
}
int main(){
    cin>>n;
    for(int z=1;z<=n;z++){
        cin>>a[z];
        str=strlen(a[z]);
        for(int x=1;x<=str;x++){
            c[z][x]=f(a[z][x*2])*16+f(a[z][x*2-1]);
            b[c[z][x]].s++;
            b[c[z][x]].sh=c[z][x];
        }
    }
    sort(b+1,b+256);
    for(int z=1;z<=16;z++){
        cout<<ff(b[z].sh);
    }
    cout<<endl;
    for(int z=1;z<=n;z++){
        for(int x=1;x<=str;x++){
            cout<<ff(fff(c[z][x]));
        }
        cout<<endl;
    }
    return 0;
}
2024/12/1 17:12
加载中...