반응형
https://www.hackerrank.com/challenges/c-tutorial-pointer/problem
#include <stdio.h>
#include <cstdlib>
void update(int *a,int *b) {
// Complete this function
int sum,minus;
sum= *a+*b;
minus = *a-*b;
*a=sum;
*b=abs(minus);
}
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;
}
반응형
'C++' 카테고리의 다른 글
[HackerRank] StringStream - Easy (0) | 2019.10.14 |
---|---|
[HackerRank]Attribute Parser - Medium (0) | 2019.10.14 |
[HackerRank] Variable Sized Arrays - Easy (0) | 2019.10.13 |
[HackerRank] Array Introduction - Easy (0) | 2019.10.12 |
[HackeRank] 함수(Functions_easy) (0) | 2019.10.01 |
댓글