问题 3348 --位数偶数个数排序(程序填空)

3348: 位数偶数个数排序(程序填空)★★★

时间限制: 1 Sec  内存限制: 128 MB
提交: 124  解决: 87
[提交][状态][命题人:]

题目描述

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;
}


输入

两行,第一行输入数字的个数n,第二行n个整数。

输出

一行,排序好的数字

样例输入
Copy
6
800 2000 62 987 64 7
样例输出
Copy
7 987 62 64 800 2000

提示

来源

[提交][状态]