fork download
  1. #include <stdio.h>
  2. int hasEOF = 0;
  3. int readchar() {
  4. static int N = 1<<20;
  5. static char buf[1<<20];
  6. static char *p = buf, *end = buf;
  7. if(p == end) {
  8. if((end = buf + fread(buf, 1, N, stdin)) == buf) {
  9. hasEOF = 1;
  10. return EOF;
  11. }
  12. p = buf;
  13. }
  14. return *p++;
  15. }
  16. int ReadInt(int *x) {
  17. char c, neg;
  18. while((c = readchar()) < '-') {if(c == EOF) return 0;}
  19. neg = (c == '-') ? -1 : 1;
  20. *x = (neg == 1) ? c-'0' : 0;
  21. while((c = readchar()) >= '0')
  22. *x = (*x << 3) + (*x << 1) + c-'0';
  23. *x *= neg;
  24. return 1;
  25. }
  26. int main() {
  27. int n;
  28. long long int bookshelf=0;
  29. while (ReadInt(&n)) {
  30. long long int flag=bookshelf;
  31. int i=0;
  32. for(i=0;i<8;i++)
  33. {
  34. if(n==(flag&255))
  35. {
  36. bookshelf=bookshelf<<(64-8*i);
  37. bookshelf=bookshelf>>(56-8*i);
  38. flag=flag>>8;
  39. bookshelf= bookshelf+(flag<<(8*i+8))+n;
  40. break;
  41. }
  42. flag=flag>>8;
  43. }
  44. if(i==8)
  45. {
  46. bookshelf=(bookshelf<<8)+n;
  47. }
  48. }
  49. printf("%lld",(bookshelf>>56));
  50. for(int j=1;j<8;j++)
  51. {
  52. printf(" %lld",((bookshelf>>(56-8*j))&255));
  53. }
  54. return 0;
  55. }
  56.  
Runtime error #stdin #stdout 0s 4540KB
stdin
1 2 3 4 5 6 7 8 6 10 23 7 4
stdout
Standard output is empty