Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <unistd.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. #define INPUT "Rgn02.txt"
  8. #define WIDTH 8 /* 6 bytes + CRLF */
  9.  
  10. unsigned char there[(2<<15)*16*16*2];
  11. static inline int num(unsigned char *reg)
  12. {
  13. register unsigned int val =
  14. (reg[0]&31) |
  15. ((reg[1]&31)<<5) |
  16. ((reg[2]&31)<<10) |
  17. ((reg[3]&15)<<15) |
  18. ((reg[4]&15)<<19) |
  19. ((reg[5]&15)<<23);
  20.  
  21. return there[(unsigned int)val>>3] ^= (1<< (val & 7));
  22. }
  23.  
  24. int main(void)
  25. {
  26. struct stat st;
  27. if(!stat(INPUT, &st)) {
  28. off_t size = st.st_size;
  29. char *data = malloc(size+1);
  30. FILE *f = fopen(INPUT, "rb");
  31. if(f) {
  32. if(size == fread(data, 1, size, f)) {
  33. int fields = size/WIDTH;
  34. int i;
  35. for(i=0; i<fields; i++) {
  36. if(!num(&data[i*WIDTH])) {
  37. printf("%u\n", i);
  38. }
  39. }
  40. }
  41. fclose(f);
  42. }
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement