int GetRand(int x) { if ( x < 0 ) x = - x; if ( x == 0 ) return 0; if ( x == RAND_MAX ) return rand( ); if ( x < RAND_MAX ) while ( 1 ) { int i = rand( ); if ( i / x != INT_MAX / x ) return i; } if ( x % RAND_MAX == 0 ) return rand( ) * ( x / RAND_MAX ); while ( 1 ) { int i = rand( ) * ( x / RAND_MAX ); if ( i >= x % RAND_MAX ) return i - x % RAND_MAX; } }
int GetRand(int x) { if ( x < 0 ) x = - x; if ( x == 0 ) return 0; if ( x == RAND_MAX ) return rand( ); if ( x < RAND_MAX ) while ( 1 ) { int i = rand( ); if ( i / x != INT_MAX / x ) return i % ( x + 1 ); } if ( x % RAND_MAX == 0 ) return rand( ) * ( x / RAND_MAX ) + GetRand( x / RAND_MAX - 1 ); while ( 1 ) { int i = rand( ) * ( x / RAND_MAX ); if ( i >= x % RAND_MAX ) return i - x % RAND_MAX; } }I
int GetRand(int x) { if ( x < 0 ) x = - x; if ( x == 0 ) return 0; if ( x == RAND_MAX ) return rand( ); if ( x < RAND_MAX ) while ( 1 ) { int i = rand( ); if ( i / x != INT_MAX / x ) return i % ( x + 1 ); } if ( x % RAND_MAX == 0 ) return rand( ) * ( x / RAND_MAX ) + GetRand( x / RAND_MAX - 1 ); while ( 1 ) { int i = rand( ) * ( x / RAND_MAX + 1 ); if ( i >= x % RAND_MAX ) return i - x % RAND_MAX; } }I