We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Introduction
- Pointer
- Discussions
Pointer
Pointer
Sort by
recency
|
1148 Discussions
|
Please Login in order to post a comment
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);
}
I think it's just math. *a = *a + *b; *b = std::abs(*a-(*b*2));
void update(int *a,int *b) { int x = *a + *b; //initializing pointers addition inside variable. int diff = *a - *b; //initializing pointers difference inside variable.
}
void update(int *a,int *b) { int num1 = (*a); int num2 = (*b); num1 = (*a) + (*b); num2 = (*a) - (*b); if (num2 < 0) { num2 = -num2; } *a = num1; *b = num2;
}
void update(int *a,int *b) { int sum= (*a)+(*b); int diff= abs((*a)-(*b));
(*a)=sum; (*b)=diff; } this may help :)