remplir un tableau a 2 dimension avec des entiers différents
bonjour
je me demande comment on peut remplir un tableau a 2 dimension via une méthode pour obtenir un tableau qui ressemble a celui la
1.1.1
2.2.2
3.3.3
j' ai essayé ce code mais ça me des 1 partout
merci pour votre aide
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
static void Matrice(int[,] MAT)
{
int LIG;
int COL;
for (LIG = MAT.GetLowerBound(0); LIG <= MAT.GetUpperBound(0); LIG++)
{
for (COL = MAT.GetLowerBound(1); COL <= MAT.GetUpperBound(1); COL++)
{
Console.Write(String.Format("{0:0 }", MAT[LIG, COL]));
}
Console.WriteLine();
}
Console.WriteLine();
}
static void matDeux(int[,] MAT)
{
int LIG;
int COL;
for (LIG = MAT.GetLowerBound(0); LIG <= MAT.GetUpperBound(0); LIG++)
{
for (COL = MAT.GetLowerBound(1); COL <= MAT.GetUpperBound(1); COL++)
{
MAT[LIG, COL] = MAT[LIG, COL] + 1;
}
}
}
static void Main()
{
int BorneTableau = 3;
int[,] Mat = new int[BorneTableau, BorneTableau];
Console.WriteLine("voila le tableau");
matDeux(Mat);
Matrice(Mat); |