Sort by

recency

|

1153 Discussions

|

  • + 0 comments
    #include <stdio.h>
    
    void update(int *a,int *b) {
        // Complete this function
        int temp_pa = *a + *b;
        int temp_pb = *a - *b;
        if (temp_pb < 0)
        {
            temp_pb = -(temp_pb); 
        }
        *a = temp_pa;
        *b = temp_pb;
        // Desired outcome in case a:4, b:5 is 9,1    
    }
    
    int main() {
        int a, b;
        int *pa = &a, *pb = &b;
        
        scanf("%d %d", &a, &b);
        update(pa, pb);
        printf("%d\n%d", a, b);
    
        return 0;
    }
    
  • + 0 comments

    include

    void SumAbs (int *a, int *b){ int temp = (*a); (*a)+=(*b);

    temp = temp - (*b);
    if(temp>=0){
        (*b)=temp;
    } else {
        (*b)=temp*(-1);
    }
    

    }

    int main() { int a, b; std::cin >> a >> b; SumAbs(&a,&b); std::cout << a << std::endl; std::cout << b << std::endl;

    return 0;
    

    }

  • + 0 comments

    include

    using namespace std;

    void update(int *a, int *b);

    int main() {

    int a, b;
    int *pA = &a, *pB = &b;
    
    cin >> a >> b;
    
    update(pA,pB);
    
    return 0;
    

    }

    void update(int *a, int *b){ cout << *a + *b << endl; if(*b > *a) cout << *b - *a ; else cout << *a - *b; }

  • + 0 comments

    include

    include

    void update(int *a,int *b) { // Complete this function

    int sum = *a + *b;
    int sub = abs(*b-*a);
    
    *a = sum;
    *b = sub;
    

    }

    int main() { int a, b; int *pa = &a, *pb = &b;

    scanf("%d %d", &a, &b);
    update(pa, pb);
    printf("%d\n%d", a, b);
    
    return 0;
    

    }

  • + 0 comments

    include

    using namespace std; void update(int &a, int &b) { int sum = a + b; int diff = abs(a - b); a = sum; b = diff; } int main() { int a, b; cin >> a >> b; update(a, b); cout << a << endl << b; return 0; }