public void ExchangeValuesOfVerticalRegions (short Region1, short Region2)
{
if (Region1!= Region2)
{
short lineTemp1;
short lineTemp2;
short lineTemp3;
for (short i = 0; i <9; i++)
{
lineTemp1 = field [i, Region1 * 3].Value;
lineTemp2 = field [i, Region1 * 3 + 1].Value;
lineTemp3 = field [i, Region1 * 3 + 2].Value;
field [i, Region1 * 3].Value = field [i, Region2 * 3].Value;
field [i, Region1 * 3 + 1].Value = field [i, Region2 * 3 + 1].Value;
field [i, Region1 * 3 + 2].Value = field [i, Region2 * 3 + 2].Value;
field [i, Region1 * 3].Value = lineTemp1;
field [i, Region1 * 3 + 1].Value = lineTemp2;
field [i, Region1 * 3 + 2].Value = lineTemp3;
}
}
}
public void MixHorizontalRegions ()
{
Random rand = new Random ();
short Region1, Region2;
//Переставляем две строки в первой тройке
Region1 = (short)(rand.Next (7654) % 3);
Region2 = (short)(rand.Next (45545) % 3);
ExchangeValuesOfHorizontalRegions (Region1, Region2);
}
public void ExchangeValuesOfHorizontalRegions (short Region1, short Region2)
{
if (Region1!= Region2)
{
short lineTemp1;
short lineTemp2;
short lineTemp3;
for (short i = 0; i <9; i++)
{
lineTemp1 = field [Region1 * 3, i].Value;
lineTemp2 = field [Region1 * 3 +1, i].Value;
lineTemp3 = field [Region1 * 3 +2, i].Value;
field [Region1 * 3, i].Value = field [i, Region2 * 3].Value;
field [Region1 * 3 +1, i].Value = field [i, Region2 * 3 + 1].Value;
field [Region1 * 3 +2, i].Value = field [i, Region2 * 3 + 2].Value;
field [Region1 * 3, i].Value = lineTemp1;
field [Region1 * 3 +1, i].Value = lineTemp2;
field [Region1 * 3 +2, i].Value = lineTemp3;
}
}