CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Mar 2018
    Posts
    40

    Some techniques in C++

    in this piece of code bit masking technique and XOR operation are used, could you please explain me about these techniques and what's the alternative ways instead of these methods?

    Code:
    for (i = 1; i <= n; i++) {
        if (i == pow(2, p)) { 
            Final[i] = 0;                 
    	p++;
        } else {
            Final[i] = b[j];
            j++;
        }
    }
    if ((i&j) == i)
        Final[i] ^= Final[j];
    and in the following code also bit masking technique is used, and why 2 for loop is used here? whats the meaning of this lines:

    Code:
    for (i = 1; i < pow(2, r); i = pow(2, x)) {                                                                                          
        for (j = 1; j <= n; j++) {
            if ((i&j) == i)
                Final[i] ^= Final[j];                                                         
        }
        x++;
        std::cout << std::endl << i <<" " <<Final[i] ;
    }
    Last edited by 2kaud; March 30th, 2018 at 04:16 AM. Reason: Formatting for readability

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured