Sort by

recency

|

1152 Discussions

|

  • + 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; }

  • + 0 comments

    include

    void update(int *a, int *b) { int original_a = *a; // Store original a value *a = *a + *b; // Update a to sum *b = (original_a - *b); if(*b<0){ b=-1; } // Update b to difference }

    int main() { int a, b; scanf("%d %d", &a, &b);

    update(&a, &b);  // Pass addresses of a and b
    printf("%d\n%d", a, b);
    
    return 0;
    

    }