i've stuck with IndexOutOfRangeException problem for a half of the day and can't find what the problem. The problem in
for (int k = 0; k < 27; k++)
{
for (int i = 0; i < H; i++)
{
Alphabet[i,0,k] = "0";
}
}
I used Alphabet[i,0,k] = "0" for debug. Actually that expection throws even with Alphabet[0,0,0], though I have initialized that array proparly. H = 5. And the code seemed to work first time
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
class Solution
{
static void Main(string[] args)
{
int L = int.Parse(Console.ReadLine());
int H = int.Parse(Console.ReadLine());
string T = Console.ReadLine();
Console.Error.WriteLine(T);
Console.Error.WriteLine(T[0]);
int stringLenght = T.Length;
string [,] Row = new string [H,L*27];
string [,,] Alphabet = new string [H,0,27];
string [,] Word = new string [H,0];
for (int i = 0; i < H; i++)
{
string initRow = Console.ReadLine();
for (int j = 0; j < (L*27); j++)
{
Row[i,j] = Convert.ToString(initRow[j]);
}
}
for (int k = 0; k < 27; k++)
{
for (int i = 0; i < H; i++)
{
Console.Error.WriteLine("k=" + k);
Console.Error.WriteLine("i=" + i);
Alphabet[i,0,k] = "0";
}
}
for (int i =0; i < stringLenght; i++)
{
switch (T[i])
{
case 'E':
for (int j=0; j < H; j++)
{
Word[j,0] = Alphabet[j,0,3];
}
break;
default: break;
}
}
for (int i=0; i<H; i++)
{
Console.WriteLine(Word[i,0]);
}
}
}
}
for (int i =0; i < stringLenght; i++)
{
switch (T[i])
{
case 'E':
for (int j=0; j < H; j++)
{
Word[j,0] = Alphabet[j,0,3];
}
break;
default: break;
}
}
for (int i=0; i<H; i++)
{
Console.WriteLine(Word[i,0]);
} }
}