时间限制: 1 Sec 内存限制: 128 MB
    题目描述
    本题要求编写程序,对输入的一个整数,从高位开始逐位分割并输出它的各位数字。
    输入
    输入在一行中给出一个长整型范围内的非负整数。
    输出
    从高位开始逐位输出该整数的各位数字,每个数字后面有一个空格。
    样例输入
    123456
    样例输出
    1 2 3 4 5 6

    1. //#define _CRT_SECURE_NO_WARNINGS
    2. #include <math.h>
    3. #include <stdio.h>
    4. int main()
    5. {
    6. int n, count = 0;
    7. scanf("%d", &n);
    8. int t = n;
    9. if (n == 0)
    10. {
    11. printf("%d ", 0);
    12. }
    13. else
    14. {
    15. while (n != 0)
    16. {
    17. n = n / 10;
    18. count++;
    19. }
    20. while (count > 0)
    21. {
    22. count--;
    23. printf("%d ", t / (int)pow(10, count));
    24. t = t % (int)pow(10, count);
    25. }
    26. }
    27. return 0;
    28. }