这里假设不含有前导0
#include<stdio.h> int main() { int n; scanf("%d",&n); int res = 0; while(n > 0) { int i = n%10; res = res * 10 + i; n = n / 10; } printf("%d\n",res); }