免费h5杭州seo网站推广排名
分析 写一个node结构 定义两个数一个存数值 一个存图形个数
分解每个输入的数 的每一位 为每个输入的数赋值一个封闭图形个数的值作为判断依据
重写 cmp函数作为 sort的判断依据
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
int a[10] ={1,0,0,0,1,0,1,0,2,1} ;struct node {int num;int value;bool operator < (const node &a)const {return num<a.num; }
}b[N];void pow(int x,int i){b[i].value = x ;while(x){int t = x%10;b[i].num += a[t];x/=10;}}
bool cmp(node a ,node b){if(b.num < a.num ){return false;}else if(a.num < b.num ){return true;}else if(a.num == b.num ){return a.value <b.value ;}
}int main(){int n;cin>>n;for(int i = 0;i<n;i++){int x;cin>>x;pow(x,i);}sort(b,b+n,cmp);for(int i = 0;i<n;i++){cout<<b[i].value <<' ' ;}return 0;
}