1
任何人都可以幫助我。我試圖計算某些數字出現在表格佈局行中的次數 - 換句話說,垂直和水平。我想在(4和5)之間填入一組數字,以使數字表示4只出現4次和5次,只出現兩次(水平垂直&),例如6 * 6 ..注意事項Android - 計算時間兩個數字出現在單元格號碼
我該如何處理這些問題?
public boolean hasRepeatedNumbers(int[] x) {
int[] y = new int[x.length];
System.arraycopy(x, 0, y, 0, y.length);
Array.sort(y);
int i;
for (i = 1; i < y.length; i++) {
if (y[i] == y[i-1]) return true;
}
return false;
}
或
private int[] calculateUsedCells(int x, int y) {
int c[] = new int[2];
// horizontal
for (int i = 0; i < 2; i++) {
if (i == y)
continue;
int t = getCell(x, i);
if (t != 0)
c[t - 1] = t;
}
}
任何意見將是巨大的,謝謝。
說實話 - 我該如何編寫代碼,你給出的答案對我來說不是很明顯。任何幫助將被讚賞 – mascourt 2012-02-23 18:15:06