sort

「sort」の編集履歴(バックアップ)一覧はこちら

sort」(2013/10/04 (金) 11:33:05) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

-クイックソート(昇順)~ a[]を基準にしてb[]も入れ替える~ l=0,r=a.length-1で始める #highlight(java){{ void quickSort_ascend(int[] a, int[] b, int l, int r) { if (l < r) { int w = a[(l+r)/2]; int i = l, j = r, temp; while (i < j) { while (a[i] < w) i++; while (a[j] > w) j--; if (i <= j) { temp = a[i]; a[i] = a[j]; a[j] = temp; temp = b[i]; b[i] = b[j]; b[j] = temp; i++; j--; } } quickSort_ascend(a, b, l, j); quickSort_ascend(a, b, i, r); } } }} -クイックソート(降順)~ a[]を基準にしてb[]も入れ替える~ l=0,r=a.length-1で始める #highlight(java){{ void quickSort_descend(int[] a, int[] b, int l, int r) { if (l < r) { int w = a[(l+r)/2]; int i = l, j = r, temp; while (i < j) { while (a[i] > w) i++; while (a[j] < w) j--; if (i <= j) { temp = a[i]; a[i] = a[j]; a[j] = temp; temp = b[i]; b[i] = b[j]; b[j] = temp; i++; j--; } } quickSort_descend(a, b, l, j); quickSort_descend(a, b, i, r); } } }}

表示オプション

横に並べて表示:
変化行の前後のみ表示: