给出一个不多于3位的正整数n要求:求出它是几位数;分别打印出每一位数字数字之间加一个空格;按逆序打印出各位数字数字之间加一个空格用c语言实现
#include <stdio.h>
int main() {
int n, count = 0;
scanf("%d", &n);
int temp = n;
while (temp != 0) {
count++;
temp /= 10;
}
printf("%d\n", count);
while (n != 0) {
printf("%d ", n % 10);
n /= 10;
}
printf("\n");
n = temp;
while (n != 0) {
printf("%d ", n % 10);
n /= 10;
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/NfN 著作权归作者所有。请勿转载和采集!