Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 网格列接触确定算法_Java_Algorithm - Fatal编程技术网

Java 网格列接触确定算法

Java 网格列接触确定算法,java,algorithm,Java,Algorithm,我正在寻找一种有效的算法来确定用户触摸了屏幕的6列中的哪一列。可用信息是用户触摸屏幕网格的哪个单元格。屏幕的网格看起来像: Top Bezel |1 2 3 4 5 6 | |7 8 9 10 11 12| |13 14 15 16 17 18| |19 20 21 22 23 24| |25 26 27 28 29 30| |31 31 32 33 34 35| |36 37 38 39 40 41| ...etc. (21 rows total) 例如,如果用

我正在寻找一种有效的算法来确定用户触摸了屏幕的6列中的哪一列。可用信息是用户触摸屏幕网格的哪个单元格。屏幕的网格看起来像:

     Top Bezel
|1  2  3  4  5  6 |
|7  8  9  10 11 12|
|13 14 15 16 17 18|
|19 20 21 22 23 24|
|25 26 27 28 29 30|  
|31 31 32 33 34 35|
|36 37 38 39 40 41|
...etc. (21 rows total)
例如,如果用户触摸单元格#10,我想找到一个可以用Java实现的算法来确定触摸发生在第3列。如果用户触摸了单元格#13,我想确定他们触摸了列0

如何在Java方法中高效地实现这一点

int column(int cell) { return (cell - 1) % 6; }