4-9 统计个位数字

int Count_Digit(const int N, const int D) {
	if (N == 0 && D == 0)return 1;
	int tmp = N;
	int count = 0;
	if (tmp < 0)tmp *= -1;
	while (tmp) {
		if (tmp % 10 == D)
			count++;
		tmp /= 10;
	}
	return count;
}

猜你喜欢

转载自blog.csdn.net/weixin_37378399/article/details/79834798
今日推荐