void 拆解整数对号入座重组(int& 数, bool 选 = true) { int 对号[10]{}, j = 选 ? 9 : 0, 反 = 0, 基 = 1; while (数)++对号[数 % 10], 数 /= 10; if (选)while (j >= 0)if (对号[j])数 *= 10, 数 += j, (反 ? 基 *= 10 : 0), 反 += 基 * j, --对号[j]; else --j; else while (j < 10)if (对号[j])数 *= 10, 数 += j, --对号[j]; else ++j; //j = 数; while (j)反 *= 10, 反 += j % 10, j /= 10; cout << 反 << ends; } int shu = 11442233; 拆解整数对号入座重组(shu); cout << shu << ends; 拆解整数对号入座重组(shu, false); cout << shu << endl;
int shu = 184020973;