-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointer.cpp
More file actions
34 lines (25 loc) · 716 Bytes
/
Pointer.cpp
File metadata and controls
34 lines (25 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* update function has the following parameters:
int *a: an integer
int *b: an integer
The function is declared with a void return type, so there is no value to return. Modify the values in memory so that a contains their sum and b contains their absoluted difference.
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
void update(int *a, int *b) {
int sum = *a + *b;
int diff = abs(*a - *b);
*a = sum;
*b = diff;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int a, b;
cin >>a>>b;
update(&a, &b);
cout << a << endl << b << endl;
return 0;
}