koding C# Menyuserkan Mtrik
Menyuserkan Mtrik
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Matrik 2 dimensi");
int[,] myMatriks;
myMatriks = new int[3, 3];
//mengisi matrik
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
//myMatriks[i, j] = i * j;
Console.Write("masukkan nilai array ke " + i + "," + j + " : ");
int a = int.Parse(Console.ReadLine());
myMatriks[i, j] = a;
}
}
//mencetak matrik
Console.WriteLine();
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(myMatriks[i, j] + "\t");
}
Console.WriteLine();
Console.WriteLine();
Console.ReadLine();
}
}
}
}
0 komentar: