PTA 7-7 求整数的位数及各位数字之和 (15分)_第1张图片

#include
int main()
{
    unsigned long int a;
    int b, c,d;
    int sum = 0;
    int count = 1;
    scanf("%ld", &a);
    c = a;
    while (c=c/10)
    {
        count++;
    }
    b = count;
    while(count--)
    {
        d = a % 10;
        sum += d;
        a = a / 10;
    }
    printf("%d %d", b, sum);
}