/* reverse.cpp * Anthony Larrain * * Demonstrates C / C++ static arrays. */ #include #include using namespace std; void reverse (int scores[], int size); void print (const int *scores, int size); int main(int argc, char *argv[]) { const int LEN = 9; int scores [LEN] = {1,2,3,4,5,6,7,8,9}; print(scores,LEN); reverse(scores,LEN); print(scores, LEN); system("PAUSE"); return EXIT_SUCCESS; } void reverse (int scores [], int size){ for(int begin = 0, end = size - 1; begin < end; ++begin, --end){ int temp = scores[begin]; scores[begin] = scores[end]; scores[end] = temp; } } void print (const int *scores, int size){ const char space = ' '; for(int i = 0; i < size; ++i){ cout << *(scores + i) << space; } cout << endl; }