link to ques-https://hack.codingblocks.com/contests/c/457/360
#include
#include
using namespace std;
void Print(int n)
{ cout<<0<<" ";
for(int i = 1; i <= 9; i ++){
int j = 1;
while( j <= n){
for(int m = 0; m < j ; ++ m){
if(m + j * i <= n){
cout << m + j * i << " ";
}
}
j *= 10;
}
}
}
int main()
{
int n;
cin>>n;
Print(n);
return 0;
}