[LeetCode] 统计位数为偶数的数字

题目描述

[LeetCode] 统计位数为偶数的数字_第1张图片

提示:

C++实现:

class Solution {
public:
    int findNumbers(vector& nums) {
        
        int count = 0;
        for(int i = 0;i < nums.size();i++)//size()返回容器中元素的个数
        {
	//to_string() 将数值转化为字符串,返回对应的字符串
            if((to_string(nums[i]).length() % 2 == 0))
            {
                count++;
            }
        }
        return count;
    }
};

 

你可能感兴趣的:(LeetCode)