using System;
namespace Practica4
{
internal class Practica4
{
public void Prueba()
{
// Declaramos arreglo bidimensional valores definidos
int[,] matriz1 = {
{ -1, -2, -3 },
{ 1, 5, 2 }
};
Console.WriteLine("Manipulando arreglos bidimensionales");
Console.WriteLine("Posición [0][0] = " + matriz1[0, 0]);
Console.WriteLine("Posición [0][1] = " + matriz1[0, 1]);
Console.WriteLine("Posición [1][2] = " + matriz1[1, 2]);
// Matriz 3x3 insertar valores
int[,] matriz2 = new int[3, 3];
Console.WriteLine("\nVamos a insertar desde teclado");
for (int filas = 0; filas < 3; filas++)
{
for (int cols = 0; cols < 3; cols++)
{
Console.Write("Ingresa el valor [" + filas + "," + cols + "]: ");
matriz2[filas, cols] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine(" "); // separación de filas
}
// Imprimir matriz ingresada
Console.WriteLine("\nImprimiendo matriz de enteros:");
for (int filas = 0; filas < 3; filas++)
{
for (int cols = 0; cols < 3; cols++)
{
Console.Write(matriz2[filas, cols] + " ");
}
Console.WriteLine();
}
// Matriz 3x3 para ingresar valores
int[,] matriz4 = new int[3, 3];
Console.WriteLine("\nVamos a insertar desde teclado en otra matriz");
for (int filas = 0; filas < 3; filas++)
{
for (int cols = 0; cols < 3; cols++)
{
Console.Write("Ingresa el valor [" + filas + "," + cols + "]: ");
matriz4[filas, cols] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine(" ");
}
}
// Método principal para ejecutar
static void Main(string[] args)
{
Practica4 p = new Practica4();
p.Prueba();
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: