题解 | #牛牛逆序输出#
牛牛逆序输出
https://www.nowcoder.com/practice/d981181ce18e4cce945fdf52daf037a1
#include <stdio.h> #include<math.h> int reverse(int n,int count) { if(count==1) return n; else return reverse(n/10,--count)+n%10*(int)pow(10,count); } int main(void) { int n; scanf("%d",&n); int num=n; int count=0; while(num) { count++; num/=10; } printf("%d",reverse(n,count)); return 0; }