对n个整数以每一位数字中偶数数字个数从小到大排序,若个数相同则依照数字大小从小到大排序。
n<1000
#include <iostream>
#include <algorithm>
using namespace std;
int a[110];
bool cmp(int x, int y)
{
int s1=0, s2=0;
int t1=x, t2=y;
while(t1)
{
if(____(1)_____)
s1++;
t1 /= 10;
}
while(t2)
{
if((t2%10)%2==0)
s2++;
_____(2)_______
}
if(s1 != s2)
return s1<s2;
_____(3)_____
}
int main()
{
int n;
cin>>n;
for(int i=1; i<=n; i++)
cin>>a[i];
_____(4)_______
for(int i=1; i<=n; i++)
cout<< a[i] <<" ";
return 0;
}