//Cecilia Rangel CSC5 Chapter 9, P.539, #10
//
/**************************************************************
*
* REVERSE SHIFT ELEMENT ARRAY
* ____________________________________________________________
* This program creates an array of intergers, then creates a
* shifted array of elements that flips the order of elements
*
*_____________________________________________________________
*
* OUTPUT
* Array : OUTPUT a array shifted once
* to the right
* ***************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
void reverseArray(int array[], int i);
const int SIZE = 5;
int main()
{
int i;
int array[SIZE] = {1, 2, 3, 4, 5};
cout << "Current array :" << endl;
for(i=0; i< SIZE; i++)
{
cout << array[i];
}
cout << endl << "Array in reverse: " << endl;
reverseArray(array, i);
return 0;
}
/***************************************************************************
* reverseArray
* ________________________________________________________________________
* The function should take array from main and then
* reverse the elements in the array and display the array in reverse.
*
* ************************************************************************/
void reverseArray(int array[] ,int i)
{
for(i= (SIZE-1); i >=0; i--)
{
cout << array[i];
}
}
Ly9DZWNpbGlhIFJhbmdlbAkgQ1NDNQkgQ2hhcHRlciA5LAkJCQkgUC41MzksICMxMAovLwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICoKICogIFJFVkVSU0UgU0hJRlQgRUxFTUVOVCBBUlJBWQogKiBfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KICogVGhpcyBwcm9ncmFtIGNyZWF0ZXMgYW4gYXJyYXkgb2YgaW50ZXJnZXJzLCB0aGVuIGNyZWF0ZXMgYQogKiBzaGlmdGVkIGFycmF5IG9mIGVsZW1lbnRzIHRoYXQgZmxpcHMgdGhlIG9yZGVyIG9mIGVsZW1lbnRzCiAqIAogKl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KICogCiAqIE9VVFBVVAogKiBBcnJheQkJCQk6IE9VVFBVVCBhIGFycmF5IHNoaWZ0ZWQgb25jZSAKICoJCQkJCQl0byB0aGUgcmlnaHQgCiAqICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8JCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGlvbWFuaXA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHJldmVyc2VBcnJheShpbnQgYXJyYXlbXSwgaW50IGkpOwogCmNvbnN0IGludCBTSVpFID0gNTsKaW50IG1haW4oKSAKewoJaW50IGk7CglpbnQgYXJyYXlbU0laRV0gPSB7MSwgMiwgMywgNCwgNX07CiAKIAoJY291dCA8PCAiQ3VycmVudCBhcnJheSA6IiA8PCBlbmRsOwoJZm9yKGk9MDsgaTwgU0laRTsgaSsrKQoJewoJCWNvdXQgPDwgYXJyYXlbaV07Cgl9Cgljb3V0IDw8IGVuZGwgPDwgIkFycmF5IGluIHJldmVyc2U6ICIgPDwgZW5kbDsKCXJldmVyc2VBcnJheShhcnJheSwgaSk7CglyZXR1cm4gMDsKfQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAqIHJldmVyc2VBcnJheQogKiBfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KICogVGhlIGZ1bmN0aW9uIHNob3VsZCB0YWtlIGFycmF5IGZyb20gbWFpbiBhbmQgdGhlbiAKICogcmV2ZXJzZSB0aGUgZWxlbWVudHMgaW4gdGhlIGFycmF5IGFuZCBkaXNwbGF5IHRoZSBhcnJheSBpbiByZXZlcnNlLgogKiAKICogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwp2b2lkIHJldmVyc2VBcnJheShpbnQgYXJyYXlbXSAsaW50IGkpCnsKCWZvcihpPSAoU0laRS0xKTsgaSA+PTA7IGktLSkKCXsKCQljb3V0IDw8IGFycmF5W2ldOwoJfQp9