Jak odwrócić tablicę w Pythonie
a = [1,2,3,4]
a = a[::-1]
print(a)
>>> [4,3,2,1]
Helpless Hyena
a = [1,2,3,4]
a = a[::-1]
print(a)
>>> [4,3,2,1]
//reverse char array in c
void reverse(char array[]){
int size = strlen(array); //include string.h to use strlen() function
char rev[size];
for(int i=0; i<size; i++)
rev[size-1-i] = array[i];
for(int i=0; i<size; i++)
array[i] = rev[i];
}
>>> L = [0,10,20,40]
>>> L[::-1]
[40, 20, 10, 0]
#include<stdio.h>
void main()
{
int arr[100];
int n=5;
for(int i=0;i<5;i++)
{
scanf("%d",arr+i);
}
for{int i=n;i>0;--i)
{
printf("%d",arr[i])
}
return 0;
}