Sort by

recency

|

521 Discussions

|

  • + 0 comments
    int i, j,AND,OR,XOR;
      int And_max = 0 ,Or_max = 0, Xor_max = 0 ;
      for(i = 1 ; i <n+1;i++)
      {
          for(j = i+1 ;j < n+1 ;j++)
          {
              AND = i&j;
              OR  = i|j;
              XOR = i^j;
              
              if(AND != 0 ){
                  if((AND < k)&&(AND > And_max)){
                      And_max = AND;
                  }
              }
              if(OR != 0 ){
                  if((OR < k)&&(OR > Or_max)){
                      Or_max = OR;
                  }
              }
              if(XOR != 0){
                  if((XOR < k)&&(XOR > Xor_max)){
                      Xor_max = XOR;
                  }
              }  
          }
      }
      printf("%d\n%d\n%d",And_max,Or_max,Xor_max);
    
  • + 0 comments

    include

    include

    include

    include

    //Complete the following function.

    void calculate_the_maximum(int n, int k) {int lAND=0 , lOR=0,lXOR=0; //Write your code here. for(int i = 1; i <= n; i++) { for(int j = 1; j lAND && andlOR && orlXOR && xor

    int main() { int n, k ;

    scanf("%d %d", &n, &k);
    calculate_the_maximum(n, k);
    
    return 0;
    

    }

  • + 0 comments

    void calculate_the_maximum(int n, int k) { //Write your code here. int i,j,a,b,or_val=0,and_val=0,xor_val=0,max_and_val =0,max_or_val=0,max_xor_val=0; for(i=1;i max_and_val) && (and_val max_or_val) && (or_val max_xor_val) && (xor_val

    int main() { int n, k;

    scanf("%d %d", &n, &k);
    calculate_the_maximum(n, k);
    
    return 0;
    

    }

  • + 0 comments

    include

    include

    include

    include

    //Complete the following function.

    void calculate_the_maximum(int n, int k) { int temp = 0; int maxAND =0; int maxOR =0; int maxEXOR =0;

    for(int i = 1; i < n; i++) { for(int j = (i +1); j <= n; j++) {

          temp = i & j;
          maxAND =  ((temp > maxAND) && (temp < k)) ? temp : maxAND;
    
          temp = i | j;
          maxOR =  ((temp > maxOR) && (temp < k)) ? temp : maxOR;
    
          temp = i ^ j;
          maxEXOR =  ((temp > maxEXOR) && (temp < k)) ? temp : maxEXOR;
      }
    

    } printf("%d\n", maxAND); printf("%d\n", maxOR); printf("%d\n", maxEXOR); }

    int main() { int n, k;

    scanf("%d %d", &n, &k);
    calculate_the_maximum(n, k);
    
    return 0;
    

    }

  • + 0 comments

    include

    include

    include

    include

    int main() { int n, k; int c = 0; int maxAnd = 0, maxOr = 0, maxXor = 0; scanf("%d %d", &n, &k);

    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            c = i&j; 
            if(c > maxAnd && c < k) maxAnd = c;
        }
    }
    printf("%d\n", maxAnd);
    
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            c = i|j; 
            if(c > maxOr && c < k) maxOr = c;
        }
    }
    printf("%d\n", maxOr);
    
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            c = i^j; 
            if(c > maxXor && c < k) maxXor = c;
        }
    }
    printf("%d\n", maxXor);
    
    return 0;
    

    }