using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int [,] m = new int[4,5];
int[] ordenar = new int[20];
int I, J, R, C, P, menor, K = 0;
Console.WriteLine("introduce los siguientes enteros");
for (I=0; I < 4; I++)
{
for (J=0; J < 5; J++)
{
Console.Write("m[{0},{1}]:",I,J);
m[I, J] = int.Parse(Console.ReadLine());
}
}
for(P=1; P <= 20; P++)
{
menor = m [0,0];
R=0;
C=0;
for (I=0; I < 4; I++)
{
for(J=0; J < 5; J++)
{
if(m[I,J] < menor)
{
menor = m[I,J];
R=I;
C=J;
}
}
}
ordenar[K]=menor;
m[R,C]=9999;
K++;
}
Console.WriteLine("elementos ordenados de la matriz ordenados");
for(K=0; K < 20; K++)
{
Console.Write("{0,4}", ordenar[K]);
}
Console.ReadLine();
}
}
}

No hay comentarios:
Publicar un comentario