• + 0 comments

    In the description of the the problem it lists the answer to the sample problem as
    2,3,3 However, the answer is 3,3,3 from my output, for i in 1 through n, find the maximum value of the logical and, or and xor when compared againt all integers through n that are greater than i. Consider a value only if the comparison returns a result less than .... The first combination is 1,2 and that gives 0,3,3 which makes the first number 3

    include

    int main() { // a = 5 (00000101 in 8-bit binary), b = 9 (00001001 in // 8-bit binary) unsigned int a = 1, b = 2; unsigned int c=23; // The result is 00000001 printf("a = %u, b = %u\n", a, b); printf("a&b = %u\n", a & b); // The result is 00001101 printf("a|b = %u\n", a | b); // The result is 00001100 printf("a^b = %u\n", a ^ b); printf("~a = %u\n", a = ~a); // The result is 00010010 printf("b<<1 = %u\n", b << 1); printf("a>>b = %u\n", a >> b); // The result is 00000100 printf("b>>1 = %u\n", b >> 1); printf("a|b^a= %u\n", b|c); return 0; }

    yeilds:

    a = 1, b = 2 a&b = 0 a|b = 3 a^b = 3 ~a = 4294967294 b<<1 = 4 a>>b = 1073741823 b>>1 = 1 a|b^a= 23

    Also there is no scroll bar on this text window for me so I can't edit it properly.