Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

int mayorSec = 1, mayorSecAux = 1, numeroMayorSec = 0, numeroAux = 0;

for (int i = 0; i < myArray.Length; i++)


{
// if(myArray[i] == numeroAux){ mayorSecAux +=1; }else{ mayorSecAux =0; }

var Resul = myArray[i] == numeroAux ? mayorSecAux += 1 : mayorSecAux = 0;


if (mayorSecAux > mayorSec)
{
mayorSec = mayorSecAux;
numeroMayorSec = myArray[i];
}
numeroAux = myArray[i];
}
Console.WriteLine("Longest: " + (mayorSec + 1));
Console.WriteLine("Number: " + numeroMayorSec);

string uno = string.Empty, dos = string.Empty, tres = string.Empty, cuatro =


string.Empty, cinco = string.Empty;

for (int i = 0; i < myArray.Length; i++)


{
switch (myArray[i])
{
case 1:
uno += "*";
break;

case 2:
dos
+= "*";
break;
case
3:
tres +=
"*"; break;
case 4:
cuatro += "*";
break;
case 5:
cinco
+= "*";
break;
}
}

Console.WriteLine("1: " + uno);


Console.WriteLine("2: " + dos);
Console.WriteLine("3: " + tres);
Console.WriteLine("4: " + cuatro);
Console.WriteLine("5: " + cinco);
static int n = 3;
public static void Main(String[] args)
{
int filas = n;
int columnas = n;
int x = 0;
int menor = 9;
int[,] matriz = new int[filas, columnas];
int[] camino = new int[n];

for (int i = 0; i < filas; i++)


{
for (int j = 0; j < columnas; j++)
{
matriz[i, j] = myArray[x];
x = x + 1;
Console.WriteLine(matriz[i, j]);
}
Console.WriteLine();
}
int control = 0;
for (int i = 0; i < columnas; i++)
{
for (int j = 0; j < filas; j++)
{
if (matriz[j, i] < menor)
{
if (control == j)
{
menor = matriz[j, i];
camino[i] = menor;
}
else if (control + 1 == j)
{
menor = matriz[j, i];
camino[i] = menor;
}
else if (control - 1 == j)
{
menor = matriz[j, i];
camino[i] = menor;
}
}
}
menor = 9;
Console.WriteLine();
}

for (int i = 0; i < camino.Length; i++)


{
Console.WriteLine(camino[i]);
}

Console.ReadKey();

You might also like