Răspuns:
#include <iostream>
using namespace std;
int main() {
int a, b, i, dir;
cin >> a >> b;
for ( i = 0; i < a; i ++ )
cout << i << ' ';
if ( a < b )
dir = 1;
else
dir = -1;
for ( i = a; i != b; i += dir )
cout << i << ' ';
cout << b << ' ';
return 0;
}
Explicație: