0
private void btnRodaLabirinto_Click(object sender, EventArgs e)
{
char[,] Lab = new char[10, 10];
int[,] Lab2 = new int[10, 10];
int I = 0, J = 0;
Random NumerosRandomicos = new Random();
//abaixo, setando labirinto com 0 e 1
for (I = 0; I < 10; I++)
{
for (J = 0; J < 10; J++)
{
Lab2[I, J] = NumerosRandomicos.Next(0, 2);
if (I == 9 && J == 9) Lab2[I, J] = 3;
if (I == 0 && J == 0) Lab2[I, J] = 3;
}
}
//Printando na Texbox
for (I = 0; I < 10; I++)
{
for (J = 0; J < 10; J++)
{
txtLabirinto.Text = txtLabirinto.Text +
Convert.ToString(Lab2[I, J]).ToString();
}
txtLabirinto.AppendText("\r\n");
}
}
I’ve done away with it, like this:
I = 0;
J = 0;
Lab2[I, J] = 3;
But unsuccessfully too, someone can help me?
the code works correctly! what is the error? Example running: https://ideone.com/mWYb6K (despite a bad conversion done)
– novic
What exactly doesn’t work? Just a hint, in C# we use another nomenclature standard, in general variables have names starting by lowercase
– Ricardo Pontual
The 0.0 position that has an if to be set 3, this being random (0 or 1). Already the 9.9 position which has an if to be set 3 too, is working
– Braian Freitas
@Braianfreitas I did even an example: https://ideone.com/mWYb6K and what you said to set to 3 happens in both positions, although the code should be improved but, what is to be done happens yes
– novic
I understand, maybe I’m making a mistake, because I attached a picture to the result question I’m getting
– Braian Freitas
@Braianfreitas I circled in a form and ran your code! no problem at all!
– novic
I understood, but thanks for the solution (I do not know why my winform is not working), here is showing the result of the photo, I went as a console application and it worked, I don’t know, I’ll sit and cry here
– Braian Freitas
I solved the problem, the Textbox (the photo I sent) was small, I increased the size and solved
– Braian Freitas