Skip to content

Instantly share code, notes, and snippets.

@keehyun2
Last active January 24, 2018 12:02
Show Gist options
  • Select an option

  • Save keehyun2/d0ca246b4609867454f0ae747909a153 to your computer and use it in GitHub Desktop.

Select an option

Save keehyun2/d0ca246b4609867454f0ae747909a153 to your computer and use it in GitHub Desktop.
/**
* int 배열에서 2개 원소를 서로 교환합니다.
* @param array 전달받은 배열
* @param fromIdx
* @param targetIdx
*/
void swap(int[] array, int fromIdx, int targetIdx) {
int temp = array[targetIdx]; // 목적지 원소를 임시 저장
array[targetIdx] = array[fromIdx];
array[fromIdx] = temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment