Advertisement
jtentor

Ayuda Punto 3

Aug 31st, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1.     class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             int[,] miMatriz = CreaMatriz();
  6.             Console.WriteLine("Matriz de {0} filas y {1} columnas", miMatriz.GetLength(0), miMatriz.GetLength(1));
  7.         }
  8.  
  9.  
  10.         static int[,] CreaMatriz()
  11.         {
  12.             int filas, columnas;
  13.  
  14.             do
  15.             {
  16.                 Console.Write("Ingrese cuantas filas: ");
  17.                 filas = int.Parse(Console.ReadLine());
  18.             } while (filas <= 0);
  19.  
  20.             do
  21.             {
  22.                 Console.Write("Ingrese cuantas columnas: ");
  23.                 columnas = int.Parse(Console.ReadLine());
  24.             } while (columnas <= 0);
  25.  
  26.             int[,] matriz = new int[filas, columnas];
  27.  
  28.             for (int i = 0; i < filas; ++i)
  29.             {
  30.                 for (int j = 0; j < columnas; ++j)
  31.                 {
  32.                     Console.Write("Ingrese el valor de la fila {0} columna {1}: ", i, j);
  33.                     matriz[i, j] = int.Parse(Console.ReadLine());
  34.                 }
  35.             }
  36.             return matriz;
  37.         }
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement