c - About hash functions -
Let's consider a bidirectional array, as declared as the following:
#include & lt; Stdbool j & gt; Bull array [N1] [N2]; I must know that there is a true value in each row of this array in the same position. For example, the following is correct:
{{1, 0, 1, 0}, {1, 0,}, {0, 0, 1, While this is false: {{1, 0, 1, 0}, {1, 0, 1, 0} {0, 0, 1,}} I have tried to do this:
Fixed UITx_T hash (Controll ball * T, size_ty n ) {Uintmax_t retv = 0U; (Size_ty i = 0; i & lt; n; ++ i) if (t [i] == true) retv | = 1 & lt; & Lt; I; Retv retire; } Static int_valid {bool n} {return n! = 0 & amp; Amp; (N and (n -1)) == 0; } Bull check (ball t [n 1] [n 2]) {uintmax_t thaas [n 1]; For (size_t i = 0; i But this is only for N1 and lt; = Sizeof (uintmax_t) * CHAR_BIT works with . Do you know the best way to solve it?
Why not just create another array that is the size of N2 (number of columns), Set it all to true , then with and each row in the end, check to see if your new array has a set bit. Bull array [N1] [N2]; // It is somehow started to produce the bulging [N2]; Int i, j; // To start the result array (j = 0; j & lt; n2; ++ j) {result [j] = 1; } // Now go through the array, calculate the result for (i = 0; i & lt; n1; ++ i) {for (j = 0; j & lt; n2; ++ j) {Results [J] & amp; = Array [i] [j]; }} // At this point, you can see the result array. // If your array is valid, then the result should have only one '1'
Comments
Post a Comment