>>848
ピボット選択のところは

for (k=0; k<N; ++k) {
  temp1 = a[i][k];
  a[i][k] = a[l][k];
  a[l][k] = temp1;
}

じゃないの?