fork download
  1. #include <cstdio>
  2. #include <cstdlib>
  3.  
  4. #define LOOK
  5. #define n 3
  6. #define k 2
  7.  
  8. typedef unsigned U32;
  9. typedef unsigned char U8;
  10.  
  11. typedef struct
  12. {
  13. U32 state : 31;
  14. U32 bit : 1;
  15. }TBB;
  16.  
  17. TBB ***branch_level;
  18. TBB *branch_space;
  19. U32 *f_branch;
  20. U32 *branch_num; //1<<f_branch
  21. U32 *state_dim;
  22. U32 *state_way; //1<<state_dim
  23. U32 *branch_way; //branch_num*state_num
  24.  
  25. void main()
  26. {
  27. U8 i, j, u, s, m, mm;
  28.  
  29. /***memory space***/
  30. f_branch = new U32 [n]; //[0,1,2]
  31. branch_num = new U32 [n]; //[1,2.4]
  32. state_dim = new U32 [n]; //[0,1,2]
  33. state_way= new U32 [n]; //[1,2.4]
  34. branch_way= new U32 [n]; //[2,4,8]
  35.  
  36. s=u=0;
  37. for(i=0; i<n; ++i)
  38. {
  39. f_branch[i]=i;
  40. branch_num[i]=1<<i;
  41. state_dim;
  42. state_way[i]=1<<i;
  43. s+=state_way[i];
  44. u+=branch_way[i];
  45. }
  46. branch_level = new TBB ** [s];
  47. branch_space = new TBB [u];
  48. branch_level[0] = (TBB **) branch_space;
  49.  
  50. for (i = 0, m = 1; m < n; ++i, ++m)
  51. {
  52. branch_level[m] = branch_level[i] + branch_way[i];
  53.  
  54. for(j=0, mm=1; mm < state_way[i]; ++j, ++mm)
  55. {
  56. branch_level[i][mm] = branch_level[i][j] + \ branch_num[i];
  57. }
  58. }
  59.  
  60. #ifdef LOOK
  61. for(i=0; i<n; ++i)
  62. {
  63. for(j=0; j<state_way[i]; ++j)
  64. {
  65. for(m=0; m<branch_num[i]; ++m)
  66. {
  67. printf("branch_level[%u][%u][%u].bit=\
  68. %u\n",i,j,m,branch_level[i][j][m].bit);
  69. printf("branch_level[%u][%u][%u].state=\
  70. %u\n",i,j,m,branch_level[i][j][m].state);
  71. }
  72.  
  73. }
  74. }
  75. #endif
  76. /****************/
  77. system("pause");
  78. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty