From a3130cde0f470c837b1d0e9f26a67b48a478adf2 Mon Sep 17 00:00:00 2001 From: Suryasis Date: Thu, 27 Jul 2017 08:32:08 +0530 Subject: [PATCH] You don't need to reverse the array --- C++/arrays-introduction.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/C++/arrays-introduction.cpp b/C++/arrays-introduction.cpp index f595e48..725a27d 100644 --- a/C++/arrays-introduction.cpp +++ b/C++/arrays-introduction.cpp @@ -7,21 +7,8 @@ using namespace std; -void printArr(int arr[], int count) { - for(int i = 0; i < count; ++i) - cout << arr[i] << ' '; + - cout << '\n'; -} - -void reverseArr(int arr[], int count) { - int temp; - for (int i = 0; i < count/2; ++i) { - temp = arr[i]; - arr[i] = arr[count-i-1]; - arr[count-i-1] = temp; - } -} int main() { int n; @@ -35,9 +22,11 @@ int main() { arr[i] = tmp; } - reverseArr(arr, n); - - printArr(arr, n); + for(int i=n-1;i>=0;i--) + { +cout<