Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Matriz
- {
- class Matriz
- {
- private int[,] mat;
- public void Cargar()
- {
- Console.Write("Cuántas filas tiene la matriz?");
- string linea;
- linea = Console.ReadLine();
- int filas = int.Parse(linea);
- Console.Write("Cuántas columnas tiene la matriz?");
- linea = Console.ReadLine();
- int columnas = int.Parse(linea);
- mat = new int[filas, columnas];
- for (int f = 0; f < mat.GetLength(0); f++)
- {
- for (int c = 0; c < mat.GetLength(1); c++)
- {
- Console.Write("Introduzca posición [" + (f + 1) + "," + (c + 1) + "]: ");
- string linea2;
- linea2 = Console.ReadLine();
- mat[f, c] = int.Parse(linea2);
- }
- }
- }
- public void Imprimir()
- {
- for (int f = 0; f < mat.GetLength(0); f++)
- {
- for (int c = 0; c < mat.GetLength(1); c++)
- {
- Console.Write(mat[f, c] + " ");
- }
- Console.WriteLine();
- }
- }
- static void Main(string[] args)
- {
- Matriz ma = new Matriz();
- ma.Cargar();
- ma.Imprimir();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement