{
short lineTemp;
for (short i = 0; i <9; i++)
{
lineTemp = field [line1, i].Value;
field [line1, i].Value = field [line2, i].Value;
field [line2, i].Value = lineTemp;
}
}
}
public void MixVerticalLines ()
{
Random rand = new Random ();
short line1, line2;
//Переставляем две строки в первой тройке
line1 = (short)(rand.Next (12432) % 3);
line2 = (short)(rand.Next (87457) % 3);
ExchangeValuesOfVerticalLines (line1, line2);
//Переставляем две строки во второй тройке
line1 = (short)(rand.Next (12432) % 3 +3);
line2 = (short)(rand.Next (87457) % 3 +3);
ExchangeValuesOfVerticalLines (line1, line2);
//Переставляем две строки в третьей тройке
line1 = (short)(rand.Next (12432) % 3 +6);
line2 = (short)(rand.Next (87457) % 3 +6);
ExchangeValuesOfVerticalLines (line1, line2);
}
public void ExchangeValuesOfVerticalLines (short line1, short line2)
{
if (line1!= line2)
{
short lineTemp;
for (short i = 0; i <9; i++)
{
lineTemp = field [i, line1].Value;
field [i, line1].Value = field [i, line2].Value;
field [i, line2].Value = lineTemp;
}
}
}
// Перестановка регионов (блок из трех строк/столбцов)
public void MixVerticalRegions ()
{
Random rand = new Random ();
short Region1, Region2;
//Переставляем две строки в первой тройке
Region1 = (short)(rand.Next (7654) % 3);
Region2 = (short)(rand.Next (45545) % 3);
ExchangeValuesOfVerticalRegions (Region1, Region2);
}