Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Core Java and Java 8
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lokesh Singh
Core Java and Java 8
Commits
29edbc8e
Unverified
Commit
29edbc8e
authored
Jan 10, 2022
by
Lokesh Singh
Committed by
GitHub
Jan 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Reverse array
parent
6bfe6d83
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
Reverse array
Reverse array
+44
-0
No files found.
Reverse array
0 → 100644
View file @
29edbc8e
#include <iostream>
using namespace std;
int main() {
//code
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
for(int i = 0; i < n; i++)
cin>>arr[i];
for(int i = n-1; i >= 0; i--)
cout<<arr[i]<<" ";
cout<<endl;
}
// return 0;
return 0;
}
//another implementation
#include <iostream>
using namespace std;
void reverse(int arr[], int start, int end)
{
int temp;
temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
reverse(arr, start+1, end+1);
}
int main() {
int arr[] = {5 , 8, 10, 13};
int n = sizeof(arr)/sizeof(arr[0]);
int start = 0, end = n-1;
cout<<reverse(arr, start, end);
return 0;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment