The difference is calculated using the new value of *a
, which is updated at *a = *a + *b;
.
The calculation should be after calculating t
.
void update(int *a,int *b) {
int t{0};
// Complete this function
if (*a>*b) {
t= (*a) - (*b) ;
}
else {
t = (*b) - (*a);
}
*a = *a + *b; // move this here
*b = t;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…