c语言学习之 正序分解整数

 1 #include <stdio.h>
 2 
 3 int main()
 4 {
 5     int x;
 6     scanf("%d", &x); //输入一个正整数
 7     int mask = 1;
 8     int t = x;
 9     
10     while ( t > 9){  
11         t = t / 10;
12         mask = mask*10;
13     } 
14     do{
15         int d = x / mask;
16         printf("%d\n", d);
17         x = x % mask;
18         mask = mask / 10;
19     } while ( mask > 0);
20     
21     printf("\n");
22     
23     return 0;
24      
25 }
原文地址:https://www.cnblogs.com/november1943/p/4659956.html