fork download
  1. #include <iostream>
  2.  
  3. int index( int n )
  4. {
  5. return 3 - ( n >> 8 ) + ( n >> 10 );
  6. }
  7.  
  8. void test( int n )
  9. {
  10. std::cout << n << " - " << index( n ) << std::endl;
  11. }
  12.  
  13. int main() {
  14. for( int i : {1024, 512, 256, 128 } )
  15. test( i );
  16. return 0;
  17. }
Success #stdin #stdout 0s 4468KB
stdin
Standard input is empty
stdout
1024 - 0
512 - 1
256 - 2
128 - 3