fork(1) download
  1.  
  2. int main() {
  3. int number;
  4. printf("请输入一个不多于五位数的整数:");
  5. scanf("%d", &number);
  6.  
  7. // 提取各个位上的数字
  8. int number_wan = number / 10000; // 提取万位
  9. int number_qian = (number % 10000) / 1000; // 提取千位
  10. int number_bai = (number % 10000 % 1000) / 100; // 提取百位
  11. int number_shi = (number % 10000 % 1000 % 100) / 10; // 提取十位
  12. int number_ge = number % 10000 % 1000 % 100 % 10; // 提取个位
  13.  
  14. // 根据不同的位数情况逆序输出
  15. if (number_wan == 0) {
  16. printf("%d %d %d %d %d\n", number_ge, number_shi, number_bai, number_qian, number_wan);
  17. } else if (number_wan != 0 && number_qian == 0) {
  18. printf("%d %d %d %d\n", number_ge, number_shi, number_bai, number_wan);
  19. } else if (number_wan != 0 && number_qian != 0 && number_bai == 0) {
  20. printf("%d %d %d\n", number_ge, number_shi, number_wan);
  21. } else if (number_wan != 0 && number_qian != 0 && number_bai != 0 && number_shi == 0) {
  22. printf("%d %d\n", number_ge, number_wan);
  23. } else if (number_wan != 0 && number_qian != 0 && number_bai != 0 && number_shi != 0 && number_ge == 0) {
  24. printf("%d\n", number_wan);
  25. } else {
  26. printf("%d %d %d %d %d\n", number_ge, number_shi, number_bai, number_qian, number_wan);
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5280KB
stdin
1
stdout
请输入一个不多于五位数的整数:1 0 0 0 0