Currently, I'm writing a program that's designed to make a user try and take a printed array of elements, randomly chosen from the values of 1 to 9 and reverse them to get them in order from 1 to 9. (However, they cannot simply pick which printed element to switch with which, they must pick how many elements in total they wish to reverse. (Example: If the array is printed 1, 2, 3, 4, 5, 6, 7, 8, 9 and the user enters 4
, the printed array would become 4, 3, 2, 1,
5, 6, 7, 8, 9))
Sorry if it's not really clear what I'm trying to do. It's a difficult concept to explain. Anyway, I've got almost everything working. Right now I'm trying to copy the printed array (Called ReverseArray) into a second, temporary array (ReverseArrayTemp) to perform the reversal and then overwrite ReverseArray with ReverseArrayTemp.
// Complex array loop. Outer for loop copies the ReverseArray to ReverseArrayTemp in alternating order (Starting from highest element in ReverseArray and the lowest in ReverseArrayTemp).
// So 9 becomes 1, 8 becomes 2, etc. After each element swap, ReverseArray element increments, and ReverseArrayTemp decrements.
for ( ReverseArray[ i ] = ReverseArrayTemp[ index ]; getInteger() < 8; ++i, --index )
// ReverseArrayTemp [ index ] = getInteger( 1, 9 );
for ( ReverseArrayTemp[ index2 ] = 0; index2 < 9; ++index2 )
while( ReverseArrayTemp[ index ] > 0 );
Everything else is working fine, I'm just stumped on how I'm supposed to word this and lay it out in coding. Any help?