fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int nibble(int val, int k) {
  5. return (val >> (4*k)) & 0x0F;
  6. }
  7.  
  8. int main() {
  9. int val = 0xf1;
  10. for (int k = 0; k != 8 ; k++) {
  11. int n = nibble(val, k);
  12. cout << n << endl;
  13. }
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
1
15
0
0
0
0
0
0