반응형
https://www.hackerrank.com/challenges/c-tutorial-pointer/problem
#include <stdio.h>
#include <cstdlib>
void update(int *a,int *b) {
// Complete this function
int a_update, b_update;
a_update = (*a) + (*b);
b_update = abs((*a) - (*b));
*a = a_update;
*b = b_update;
}
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;
}
반응형
'Training > HackerRank' 카테고리의 다른 글
[C++][Classes] Class (0) | 2021.08.07 |
---|---|
[C++][Strings] StringStream (0) | 2021.08.04 |
[C++][Implementation] Breaking the Records (0) | 2021.08.01 |
[C++][Implementation] Number Line Jumps (0) | 2021.07.30 |
[C++][Implementation] Apple and Orange (0) | 2021.07.28 |