【leetcode】统计位数为偶数的数字

 

int findNumbers(int* nums, int numsSize){
    int i,cnt,total=0,val;
    for (i=0; i<numsSize; i++)
    {
        val=nums[i];
        cnt=0;
        while(val){
            cnt++;
            val /=10;
        }
        if (cnt % 2 == 0) total++;
    }
    return total;
}

 

posted @ 2020-09-29 14:25  温暖了寂寞  阅读(149)  评论(0编辑  收藏  举报