这个是下面要输出的规则,这
个数组的每一列是下面数规则
数组的第一列: 1 1 1 1 1 1
2 2 2 3 3 4
3 4 5 4 5 5
这个是要输出的数组:
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2 1 2 3 4 5
2 3 4 5 1
4 5 1 2 3 1 2 3 4 5
2 3 4 5 1
5 1 2 3 4 1 2 3 4 5
3 4 5 1 2
4 5 1 2 3 1 2 3 4 5
3 4 5 1 2
5 1 2 3 4 1 2 3 4 5
4 5 1 2 3
5 1 2 3 4
这样输出也行:
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 3 4 5 1 2 3 4 5 1 2 4 5 1 2 3
3 4 5 1 2 4 5 1 2 3 5 1 2 3 4 4 5 1 2 3 5 1 2 3 4 5 1 2 3 4
个数组的每一列是下面数规则
数组的第一列: 1 1 1 1 1 1
2 2 2 3 3 4
3 4 5 4 5 5
这个是要输出的数组:
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2 1 2 3 4 5
2 3 4 5 1
4 5 1 2 3 1 2 3 4 5
2 3 4 5 1
5 1 2 3 4 1 2 3 4 5
3 4 5 1 2
4 5 1 2 3 1 2 3 4 5
3 4 5 1 2
5 1 2 3 4 1 2 3 4 5
4 5 1 2 3
5 1 2 3 4
这样输出也行:
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 3 4 5 1 2 3 4 5 1 2 4 5 1 2 3
3 4 5 1 2 4 5 1 2 3 5 1 2 3 4 4 5 1 2 3 5 1 2 3 4 5 1 2 3 4
http://blog.csdn.net/lmsnju/archive/2009/12/10/4980711.aspx
{
for (int j = 0; j < 3; j++)
{
for (int o = 0; o < 5; o++)
{
int value = vals[j,i] + o;
if (value > 5)
value -= 5;
Console.Write("{0} ", value);
}
Console.WriteLine();
}
}
class PrintArray { public static List<int[]> InitArray(int maxNumber, int minNumber) {
List<int[]> array = new List<int[]>();
int[] aaa = new int[3] { 1, 1, 1}; while (aaa[0] < 2) {
bool flag = false;
for (int i = 0; i < aaa.Length - 1; i++) {
if (aaa[i] >= aaa[i + 1]) {
flag = true;
break;
}
}
if (!flag) {
int[] temp = new int[aaa.Length];
for (int i = 0; i < aaa.Length; i++) {
temp[i] = aaa[i];
}
array.Add(temp);
foreach (int item in aaa) {
Console.Write("{0} ", item);
}
Console.Write("\n");
}
aaa[aaa.Length - 1]++; for (int i = aaa.Length - 1; i > 0; i--) {
if (aaa[i] > maxNumber) {
aaa[i - 1]++;
aaa[i] = minNumber;
}
}
}
Console.Write("\n\n");
return array;
} public static void Print(List<int[]> srcArray, int maxNumber, int minNumber) {
List<int[]> before = new List<int[]>();
Console.WriteLine("未翻转:");
foreach (int[] item in srcArray) {
foreach (int number in item) {
Console.Write("{0} ", number);
}
before.Add(item);
Console.Write("\n"); int ii = minNumber;
while (ii < maxNumber) {
int[] temp = new int[item.Length]; for (int i = 0; i < item.Length; i++) {
temp[i] = item[i];
} for (int i = 0; i < temp.Length; i++) {
temp[i] += ii; if (temp[i]> maxNumber) {
temp[i] %= maxNumber;
} Console.Write("{0} ", temp[i]);
} before.Add(temp); Console.Write("\n"); ii++;
}
} Console.Write("\n翻转:\n"); int[][] abc = before.ToArray(); int[,] cba = new int[abc[0].Length, abc.Length];
for (int i = 0; i < abc.Length; i++) {
for (int j = 0; j < abc[i].Length; j++) {
cba[j, i] = abc[i][j];
}
} for (int i = 0; i < abc[0].Length; i++) {
for (int j = 0; j < abc.Length; j++) {
Console.Write("{0} ", cba[i, j]);
} Console.Write("\n");
}
}
}
结果是:
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
未翻转:
1 2 3
2 3 4
3 4 5
4 5 1
5 1 2
1 2 4
2 3 5
3 4 1
4 5 2
5 1 3
1 2 5
2 3 1
3 4 2
4 5 3
5 1 4
1 3 4
2 4 5
3 5 1
4 1 2
5 2 3
1 3 5
2 4 1
3 5 2
4 1 3
5 2 4
1 4 5
2 5 1
3 1 2
4 2 3
5 3 4翻转:
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 3 4 5 1 2 3 4 5 1 2 4 5 1 2 3
3 4 5 1 2 4 5 1 2 3 5 1 2 3 4 4 5 1 2 3 5 1 2 3 4 5 1 2 3 4
int[] n = new int[] { 1, 2, 3, 4, 5 };
string str="";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 5; k++)
{
str += string.Format("{0} ", n[(ss[j, i] + k - 1) % 5]);
}
str +="\r\n";
}
str+="\r\n";
}
MessageBox.Show(str);
int[,] ss = new int[,] { { 1, 1, 1, 1, 1, 1 }, { 2, 2, 2, 3, 3, 4 }, { 3, 4, 5, 4, 5, 5 } };
int[] n = new int[] { 1, 2, 3, 4, 5 };
string str = "";
for (int j = 0; j < 3; j++)
{
for (int i = 0; i < 6; i++)
{
for (int k = 0; k < 5; k++)
{
str += string.Format("{0} ", n[(ss[j, i] + k - 1) % 5]);
}
//str += "\r\n";
}
str += "\r\n";
}
MessageBox.Show(str);