基础编程题目集 6-9 统计个位数字 (15分)

在这里插入图片描述

#include <stdio.h>
int Count_Digit(const int N, const int D);
int main()
{
    int N, D;
    scanf("%d %d", &N, &D);
    printf("%d\n", Count_Digit(N, D));
    return 0;
}
int Count_Digit(const int N, const int D)
{
    int i, j, b = 0;
    i = N;
    if (i < 0)
        i = -i;
    do
    {
        j = i % 10;
        if (j == D)
            b++;
        i /= 10;
    } while (i > 0);
    return b;
}
发布了318 篇原创文章 · 获赞 147 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_44458489/article/details/105522842
今日推荐