we have a case study to accept user input or should i say... INPUTS from user
input :: must not exceed 5 digits.
when the user inputs 0 (zero) .. it will reverse his inputs from before.
how can i reverse them??
can this could do the job?
public static void reverse(int[] b) {
int left = 0; // index of leftmost element
int right = b.length-1; // index of rightmost element
while (left < right) {
// exchange the left and right elements
int temp = b[left];
b[left] = b[right];
b[right] = temp;
// move the bounds toward the center
left++;
right--;
}
}//endmethod reverse