#include #include #include #define READ_BUFSIZE ( 16 ) #define READ_DELIMITER ( " " ) //標準入力取得(1行) int GetStdin( char* pszStr, int lMaxLen ) { int lLen = 0; memset( pszStr, 0, lMaxLen ); if( fgets( pszStr, lMaxLen, stdin ) ) { lLen = strlen( pszStr ); if( lLen >= 1 ) { if( pszStr[ lLen - 1 ] == 0x0A ) { pszStr[ lLen - 1 ] = 0; lLen--; } } } return( lLen ); } //int型のスワップ void swap( int &i, int &j ) { int k = i; i = j; j = k; } void sort( int lInput[], int lNum ) { for( int i = 0; i < lNum; i++ ) { for( int j = lNum-1; j >= i+1; j-- ) { if( lInput[ j ] < lInput[ j-1 ] ) swap( lInput[j] , lInput[ j-1 ] ); } } } int main(int argc, char *argv[]) { char szRead[READ_BUFSIZE] = ""; //char* psOutbuf[10000] = { 0 }; int lInput[4] = {0}; GetStdin( szRead, READ_BUFSIZE ); int N = atoi( szRead ); GetStdin( szRead, READ_BUFSIZE ); int * pn = new int[N]; for( int i = 0; i < N; i++ ) { GetStdin( szRead, READ_BUFSIZE ); pn[i] = atoi( szRead ); } sort( pn, N ); printf( "%d\n", pn[N-1]-pn[0] ); delete[] pn; return 0; }