int *p1 = x;
int *p2 = x + N-1;
while (p1 < p2)
{
int temp = *p1;
*(p1++) = *p2;
*(p2--) = temp;
}
std::reverse(begin(x), end(x));
a = a(ubound(a,dim=1)::-1)
for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
x[i], x[j] = x[j], x[i]
}
func reverse[T any](x []T) {
for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
x[i], x[j] = x[j], x[i]
}
}
int i, m = x.size(), n = m-- / 2;
for (i = 0; i < n; ++i) swap(x, i, m - i);
static <T> void reverse(List<T> x){
int n = x.size();
for(int i=0;i<n/2;i++){
T tmp = x.get(i);
x.set(i, x.get(n-i-1));
x.set(n-i-1, tmp);
}
}
val reversedView = x.asReversed()
function array_reverse(x)
local n, m = #x, #x/2
for i=1, m do
x[i], x[n-i+1] = x[n-i+1], x[i]
end
return x
end
rev = {}
for i=#x, 1, -1 do
rev[#rev+1] = x[i]
end
-- in-situ reversal
function reverse(t)
local n = #t
local i = 1
for i = 1, n do
t[i],t[n] = t[n],t[i]
n = n - 1
end
end
rev = {}
for i=#x, 1, -1 do
rev[#rev+1] = x[i]
end
x = rev
x.reverseObjectEnumerator.allObjects
$x = array_reverse($x, true);
var n,i: integer;
tmp:TElement;
[...]
n:= length(x);
for i := 0 to (n div 2)-1 do
begin
tmp := x[i];
x[i] := x[n-i-1];
x[n-i-1] := tmp;
end;
var n,i: integer;
[...]
n:= length(x);
setlength(x, n+1);
for i := 0 to (n div 2)-1 do
begin
x[n] := x[i];
x[i] := x[n-i-1];
x[n-i-1] := x[n];
end;
setlength(x, n);
my @list = ('words', 'of', 'list', 'a', 'reverse');
my @reversed = reverse @list;
let y: Vec<_> = x.into_iter().rev().collect();
Dim ItemList As New List(Of String)(New String() {"one", "two", "three"})
ItemList.Reverse()
For Each item In ItemList
Console.WriteLine(item)
Next