#include <iostream> #include <cstdio> using namespace std; int main(){ int buf[5];//用buf保存从整数中拆解出来的数位数字 for(int i = 1000; i <= (10000 / 9); i++){ int tmp = i, num = 0, pos = 0;//tmp记录i的值,num记录反序数,pos记录当前下标 while(tmp > 0){ buf[pos] = tmp % 10; num = num * 10 + buf[pos++]; tmp /= 10; } if(num == (i * 9)){ printf("%d\n", i);//1089 } } return 0; }