采用字符串拼接和类型转化的方式进行 unsigned int x,t; int y = 1; string str; cin >> x; t = x; while (t / 10) { t /= 10; y++; } for (int i = 0; i < y; i++) { int z = x % 10; x /= 10; char c = char('0' + z); str += c; } cout << str;