#include <stdio.h> #include<malloc.h> int* arr; int Arrlen(int num) { int len = 0; while (num) { num /= 10; len++; } return len; } int* Arrcul(int num, int len) { arr = (int*)malloc(len * sizeof(int)); int index = 0; while (num) { arr[index++] = num % 10; num /= 10; } return arr; } int main() { int n; scanf("%d", &n); int len = Arrlen(n); if (n == 0) //n为0时 printf("%d", 0); Arrcul(n, len); for (int i = 0; i < len; i++) printf("%d", arr[i]); }