Given a number, e.g., 2789, as an array [2,7,8,9]. Write a method that returns the array incremented by one: i.e. [2,7,9,0].
Code input/output:
int [] A = {9, 8, 9, 9};
incrementByOne(A);
9 9 0 0
int [] B = {9, 9, 9, 9};
incrementByOne(B);
1 0 0 0 0
int [] C = {2, 7, 8, 9};
incrementByOne(C);
2 7 9 0
Code input/output:
int [] A = {9, 8, 9, 9};
incrementByOne(A);
9 9 0 0
int [] B = {9, 9, 9, 9};
incrementByOne(B);
1 0 0 0 0
int [] C = {2, 7, 8, 9};
incrementByOne(C);
2 7 9 0
No comments:
Post a Comment