由于大数溢出的问题,所以使用字符串模拟大数
class Solution {
public:
vector<string> printNumbers(int n) {
vector<string> ans{ "1","2","3","4","5","6","7","8","9" };
int beg = 0, end = 8;
for (int i = 2; i <= n; ++i)
{
for (int k = beg; k <= end; ++k)
{
for (int j = 0; j <= 9; ++j)
ans.emplace_back(ans[k] + to_string(j));
}
beg = end + 1, end = ans.size() - 1;
}
/*for (int i = 0; i < ans.size(); ++i)
{
cout << ans[i] << ' ';
if (i % 10 == 0)
cout << endl;
}*/
return ans;
}
};