有一種方法可以根據索引獲取 X 和 Y,例如
x = index % columns;
y = index / columns;
我怎樣才能扭轉這個并獲得基于 X 和 Y 的索引?
uj5u.com熱心網友回復:
假設我們在這里處理整數,如果您有以下代碼:
x = index % columns; // get the remainder of dividing index by columns
y = index / columns; // get the result of dividing index by columnsn
然后反過來是:
index = y * columns x;
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/449492.html
上一篇:For回圈沒有完成
