题解 | #牛牛逆序输出#
牛牛逆序输出
https://www.nowcoder.com/practice/d981181ce18e4cce945fdf52daf037a1
#include <stdio.h> int main() { int n; scanf("%d", &n); int count = 0; int num = n; while (num) { //首先计算出这个整数有多少位 num = num/10; count++; } int arr[count]; for (int i = 0; i < count; i++) { arr[i] = n%10; //把整数取余放入数组中 n = n/10; printf("%d",arr[i]); //因为逆序输出,取余正好是逆序输出 } return 0; }