兩個迴圈列舉所有可能
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i == j) continue;
...
}
https://ideone.com/qxoOxb