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 Matrixd
- {
- class Matrix
- {
- private int[,] mat; // creacion de matriz
- public void Cargar()
- {
- Console.Write("Ingrese la cantidad de filas de la matriz:");
- string linea; //guardado de valor
- linea = Console.ReadLine();//lector
- int filas = int.Parse(linea);
- Console.Write("Ingrese la cantidad de columnas de la matriz:");
- linea = Console.ReadLine();
- int columnas = int.Parse(linea);
- mat = new int[filas, columnas];
- //estructura repetitiva se acotan preguntando a la misma matriz la cantidad de filas y la cantidad de columnas para el valor
- for (int f = 0; f < mat.GetLength(0); f++)
- {
- for (int c = 0; c < mat.GetLength(1); c++)
- {
- Console.Write("Ingrese el valor:");// ingresa el valor
- linea = Console.ReadLine();
- mat[f, c] = int.Parse(linea);
- }
- }
- }
- //Impresion de la matriz
- 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)
- {
- Matrix ma = new Matrix();
- ma.Cargar();
- ma.Imprimir();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement