reverse array
#The original array
arr = [11, 22, 33, 44, 55]
print("Array is :",arr)
res = arr[::-1] #reversing using list slicing
print("Resultant new reversed array:",res)
reverse array
#The original array
arr = [11, 22, 33, 44, 55]
print("Array is :",arr)
res = arr[::-1] #reversing using list slicing
print("Resultant new reversed array:",res)
reverse array in a new array
#include <iostream>
#include <iomanip>
using namespace std;
void reverseArray(int array[],int newArray[],int size);
void printArray (int array[],int size);
int main()
{
int list [6],newList[6];
for(int i=0;i<6;i++){
cout<<"Element "<<i<<": ";
cin>>list[i];
}
reverseArray(list,newList,6);
cout<<"Original array: \n";
printArray (list,6);
cout<<endl<<"Reversed array: \n";
printArray (newList,6);
}
void reverseArray(int array[],int newArray[],int size){
for(int i=0,j=size-1;i<size;i++,j--)
newArray[j]=array[i];
}
void printArray (int array[],int size){
for(int i=0;i<size;i++)
cout<<setw(5)<<array[i];
}
Reverse an array java script
import React, { Component } from 'react';
export default class Slideshows extends Component {
constructor(){
super();
this.state = {
data:[
{ "id": "1", "name": 'Robert', "age": "21" },
{ "id": "2", "name": 'Sam', "age": "33" },
{ "id": "3", "name": 'Jerry', "age": "42" },
]
}
}
render() {
const reverseData = this.state.map((data, i) => {
return (
<li> {data.name} | {data.age} </li>
)
})
return (
<ul>
{reverseData}
</ul>
)
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us