fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. uint8_t i=0; // 0 1 3 7 15
  4. uint8_t mass[10] = {0b00000000, 0b00000001, 0b00000011, 0b00000111, 0b00001111,
  5. // 31 63 127 255 255
  6. 0b00011111, 0b00111111, 0b01111111, 0b11111101, 0b10111111
  7. };
  8. uint8_t reverse (uint8_t d)
  9. {
  10. uint8_t a, b;
  11. static const uint8_t revTable[] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};
  12. a = d >> 4;
  13. a = revTable[a];
  14. b = d & 0x0F;
  15. b = (revTable[b])<<4;
  16.  
  17. return (b | a);
  18. }
  19. int main(void) {
  20. // your code goes here
  21. for(i=0; i<(sizeof(mass)/2); i++){
  22. uint8_t q = mass[i];
  23. mass[i] = mass[sizeof(mass)-1-i];
  24. mass[sizeof(mass)-1-i] = q;
  25. }
  26. for(i=0; i<10; i++){
  27. mass[i] = reverse (mass[i]);
  28. }
  29.  
  30.  
  31. for(i=0; i<10; i++){
  32. printf("%d", mass[i]);
  33. printf(",");
  34. }
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
253,191,254,252,248,240,224,192,128,0,