Wednesday, April 13, 2016

UVA Problem 1225 : Digit Counting -Solution

Unknown
#include <stdio.h>
int main ()
{
    int test, n,i,num;
    scanf("%d",&test);
    while (test--)
    {
        int output[10]={0,0,0,0,0,0,0,0,0,0};
        scanf("%d",&n);
        for ( i=1;i<=n;i++)
        {
            num=i;
            while (num)
            {
                ++output[num%10];
                num/=10;
            }
        }
        for (i=0;i<10;i++)
        {
            if (i) printf(" ");
            printf("%d",output[i]);
        }
        printf("\n");
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,