-
-
Save parzibyte/9e1e6fa097403106188646b780504b0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
// https://parzibyte.me/blog | |
namespace App | |
{ | |
class Programa | |
{ | |
static void Main(string[] args) | |
{ | |
int[] arreglo = { 50, 20, 90, 10, 9 }; | |
Console.WriteLine("Antes de invertir: "); | |
foreach (var elemento in arreglo) | |
{ | |
Console.WriteLine(elemento); | |
} | |
for (int indiceDelExtremoIzquierdo = 0; indiceDelExtremoIzquierdo < arreglo.Length / 2; indiceDelExtremoIzquierdo++) | |
{ | |
int indiceDelExtremoDerecho = arreglo.Length - indiceDelExtremoIzquierdo - 1; | |
int temporal = arreglo[indiceDelExtremoDerecho]; | |
arreglo[indiceDelExtremoDerecho] = arreglo[indiceDelExtremoIzquierdo]; | |
arreglo[indiceDelExtremoIzquierdo] = temporal; | |
} | |
Console.WriteLine("Después de invertir: "); | |
foreach (var elemento in arreglo) | |
{ | |
Console.WriteLine(elemento); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment