Jak w c# wyświetlić w formie macierzy tablice dwuwymiarową o rozmiarze 2x3, proszę o pomoc
0
1
using System;
public class Test
{
public static void Main()
{
long[,] arr = new long[5, 4] { { 1, 2, 3, 4 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 3, 3, 3, 3 }, { 4, 4, 4, 4 } };
int rowLength = arr.GetLength(0);
int colLength = arr.GetLength(1);
for (int i = 0; i < rowLength; i++)
{
for (int j = 0; j < colLength; j++)
{
Console.Write(string.Format("{0} ", arr[i, j]));
}
Console.Write(Environment.NewLine + Environment.NewLine);
}
Console.ReadLine();
}
}
0
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication29
{
class Program
{
static void Main(string[] args)
{
int[,] tab = new int[2,3];
Console.WriteLine("Podaj elementy tablicy");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write("tabA[{0},{1}]: ", i, j);
tab[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
Console.Clear();
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(tab[i, j] + "\t");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
czy to także jest wyświetlenie w formie macierzy?