/*
Given N, print the numbers in the range N in lexicographical order
Where lexicographical order means the order followed by the dictionary
for suppose for value N=15, the lexicographical order in range 1 to N is
1 10 11 12 13 14 15 2 3 4 5 6 7 8 9
*/
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
int n;
cin>>n;
vector<string> v;
for(int i=1;i<=n;i++){
v.push_back(to_string(i));
}
sort(v.begin(),v.end());
vector<int> lex_arr;
for(int i=0;i<v.size();i++){
lex_arr.push_back(stoi(v[i]));
}
for(int i=0;i<lex_arr.size();i++){
cout<<lex_arr[i]<<" ";
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: