swapEnds: swap the first and last

Given an array of ints, swap the first and last elements and return the changed array. The array will be length 1 or more. Step through swapEnds: a swap needs a third place to hold a value. Without temp, the first value would be lost as soon as the last one is copied over it. This code changes the array it was given and returns it.