CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cstdlib>
#include <exception>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main( void ) try {
string in;
cin >> in;
const long int cVal { strtol( in.c_str(), nullptr, 10 ) };
if ( 1 >= cVal || LONG_MIN == cVal || LONG_MAX == cVal ) {
cerr << "Wrong value." << endl;
return 0;
}
for ( long int currentVal { 1 }; currentVal <= cVal; ++currentVal ) {
array< char, 32 > buffer;
buffer.fill( 0 );
sprintf( buffer.data(), "%d", currentVal );
string currentStr( buffer.data() );
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run