P1980 计数问题 试计算在区间 11 到 n n的所有整数中,数字 x(0 ≤ x ≤ 9)x(0≤x≤9)共出现了多少次?例如,在 11到 11 11中,即在 1,2,3,4,5,6,7,8,9...

#include 
#include 

int main()
{
    int n, x, i, j, m, N, s[10], a, b, c, d, e, f, h;
    scanf("%d %d", &n, &x);
    m = 0;
    for (i=1; i<=n; i++)    //n次循环,遍历n个数
    {
        a = i/1000000;          //分解1000000内数字的各个位数字
        b = (i%1000000) / 100000;
        c = (i%100000) / 10000;
        d = (i%10000) / 1000;
        e = (i%1000) / 100;
        f = (i%100) / 10;
        h = i%10;
        s[0] = h;       //将各个位上的数字赋值到数组s中
        s[1] = f;
        s[2] = e;
        s[3] = d;
        s[4] = c;
        s[5] = b;
        s[6] = a;
        if(i < 10) N = 1;       //判断数字位数,将位数赋值给N作为循环搜索条件
        if(9

转载于:https://www.cnblogs.com/Tristan-Adams/p/9648005.html

你可能感兴趣的:(P1980 计数问题 试计算在区间 11 到 n n的所有整数中,数字 x(0 ≤ x ≤ 9)x(0≤x≤9)共出现了多少次?例如,在 11到 11 11中,即在 1,2,3,4,5,6,7,8,9...)