#include <iostream>
using namespace std;
main( )
{
int n;
cout << "Enter number of Integer in array " << endl;
cin >> n;
int num[ n] ;
cout << "Enter elements of array " << endl;
for ( int p= 0 ; p< n; p++ )
cin >> num[ p] ;
for ( int k= 0 ; k< n- 1 ; k++ )
{
if ( ( num[ k] - num[ k+ 1 ] == 1 ) || ( num[ k+ 1 ] - num[ k] == 1 ) || ( num[ k] == num[ k+ 1 ] ) )
{
cout << "No intermediate element in between these " << num[ k] << " & " << num[ k+ 1 ] << " elements" ;
}
else if ( num[ k] < num[ k+ 1 ] )
{
cout << "Element between " << num[ k] << " and " << num[ k+ 1 ] << " is/are " ;
for ( int a= num[ k] ; a< num[ k+ 1 ] - 1 ; )
{
cout << ++ a<< " " ;
}
cout << endl;
}
else if ( num[ k] > num[ k+ 1 ] )
{
cout << "Element between " << num[ k] << " and " << num[ k+ 1 ] << " is/are " ;
for ( int a= num[ k+ 1 ] ; a< num[ k] - 1 ; )
{
cout << ++ a<< " " ;
}
cout << endl;
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwptYWluKCkKewoJaW50IG47Cgljb3V0PDwiRW50ZXIgbnVtYmVyIG9mIEludGVnZXIgaW4gYXJyYXkgIjw8ZW5kbDsKCWNpbj4+bjsKCWludCBudW1bbl07Cgljb3V0PDwiRW50ZXIgZWxlbWVudHMgb2YgYXJyYXkgIjw8ZW5kbDsKCWZvcihpbnQgcD0wO3A8bjtwKyspCgljaW4+Pm51bVtwXTsKCWZvcihpbnQgaz0wO2s8bi0xO2srKykKCXsKCQlpZigobnVtW2tdLW51bVtrKzFdPT0xKSB8fCAobnVtW2srMV0tbnVtW2tdPT0xKSB8fCAobnVtW2tdPT1udW1baysxXSkpCgkJewoJY291dDw8Ik5vIGludGVybWVkaWF0ZSBlbGVtZW50IGluIGJldHdlZW4gdGhlc2UgIjw8bnVtW2tdPDwiICYgIjw8bnVtW2srMV08PCIgZWxlbWVudHMiOwoJfQoJCWV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