Question link : https://hack.codingblocks.com/contests/c/509/202
My Code Link: https://ide.codingblocks.com/#/s/32884
in this problem what is the error??
Question link : https://hack.codingblocks.com/contests/c/509/202
My Code Link: https://ide.codingblocks.com/#/s/32884
in this problem what is the error??
no code is written in ide
please try once again
#include
using namespace std;
void reverseArray(int arr[],int start,int end){
while(start<end){
int temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end–;
}
}
void printArray(int arr[], int n){
for(int i=0;i<n;i++){
cout<<arr[i]<<endl;
}
}
int main(int argc, char const *argv[])
{
int n;
cin>>n;
int arr[100];
for(int i=0;i<n;i++){
cin>>arr[i];
}
reverseArray(arr,0,n);
printArray(arr,n);
return 0;
}
use long long int for int n and for array also
and in reverse array replace end- with end–
The size of the array is the problem.
Array can only hold 100 elements. So make array size as 10^6 instead of 100.
No need to use long long. Numbers are in integer range.
Pass n-1 in reverse array function. As last element is at Index n-1.