Sort by

recency

|

1162 Discussions

|

  • + 0 comments
    #include<bits/stdc++.h>
    using namespace std;
    
    void update(int a, int b)
    {
        int t1=a,t2=b;
        a=t1+t2;
        b=abs(t1-t2);
        cout<<a<<endl<<b; 
    }
    int main()
    {
        int a=0,b=0;
        cin>>a>>b;
        update(a,b);
        return 0;
    }
    
  • + 0 comments
    void update(int *a,int *b) {
        *a = *a + *b;
        *b = abs((*b)*2 - *a); 
    }
    
  • + 0 comments
    #include <stdio.h>
    #include <stdlib.h>
    
    void update(int *a,int *b) {
        // Complete this function
        *a = *a + *b;
        *b = abs(*b - (*a - *b));
    }
    
  • + 0 comments

    use cpp 20

    include

    include

    include

    include

    include

    using namespace std;

    // Function to update sum and absolute difference via pointers void update(int *a, int *b) { int sum = *a + *b; int diff = *a - *b; if (diff < 0) diff = -diff; // Absolute value *a = sum; *b = diff; }

    int main() { int a, b; cin >> a >> b; update(&a, &b); cout << a << endl << b << endl; return 0; }

  • + 0 comments
    void update(int *a,int *b) {
        int temp = *a; // copy the value of a 
        *a = *a + *b; 
        *b = abs(temp - *b);      
    }
    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;
    }