I\'m trying to reorganize an array based on the first occurrence of a value (thus simulating similar functionality to a circular array.)
For example, in the followin
C# answer: input : { 1, 2, 3, 5, 6, 7, 8 }; Output : { 8, 7 1, 2, 3, 5, 6};
{
static void Main(string[] args)
{
int[] array = { 1, 2, 3, 5, 6, 7, 8 };
int index = 2;
int[] tempArray = new int[array.Length];
array.CopyTo(tempArray, 0);
for (int i = 0; i < array.Length - index; i++)
{
array[index + i] = tempArray[i];
}
for (int i = 0; i < index; i++)
{
array[i] = tempArray[array.Length -1 - i];
}
}
}