@Test
public void testNaturalTraslateMatrix(){
int row = 7;
int column = 8;
int total = row * column;
String[] rowStrList = new String[row];
for (int k = 0; k < row; k++) {
rowStrList[k] = "row" + k;
}
String[] columnStrList = new String[column];
for (int k = 0; k < column; k++) {
columnStrList[k] = "column" + k;
}
for (int k = 1; k <= total; k++) {
int i = k / column;
int j = k % column - 1;
String currentRowStr = (j == -1) ? rowStrList[i-1] : rowStrList[i];
String currentColumnStr = (j == -1) ? columnStrList[column - 1] : columnStrList[j];
System.out.println("自然数: " + k + ", 行位置:" + currentRowStr + "列位置:" + currentColumnStr);
}
}
想想有什么应用场景???