this is my first post. I'm taking a programming course right now and my current assignment is to create an integer (we will call it the ant) which will move around to all integers in a 2d array (randomized path). Here is my code thus far:
namespace Ant
{
class Program
{
static void Main(string[] args)
{
int ant;
int i = 0;
int[,] numberGrid =
{
{1, 2},
{3, 4},
{5, 6},
{7, 8},
{9, 10},
{10, 11},
{11, 12},
{13, 14},
{15, 16},
{17, 18},
{19, 20},
};
do
{
Random rand = new Random();
ant= rand.Next(numberGrid[10, 1]);
Console.WriteLine(ant);
i++;
} while (i !=110);
Console.WriteLine("It took {0} steps for the ant to cover all spaces!", i);
}
}
}
I have the 2d array and I have temporarily set the ant up for a randomized path which will go on for 110 times before it stops. I'm supposed to integrate struct into this so that the ant will only go until it has visited all the integers of the 2d array instead of a set amount of times, but I'm absolutely clueless as to how I'm supposed to do this. If anyone could help me understand that would be great, thank you!