Beautiful Code

วันนี้ได้ไปอ่านหนังสือ Beautiful Code มา มีตอนนึงเค้าเขียนไว้ว่า

?A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.?


void quicksort(int l, int u){
     int i, m;
     if (l >= u){
          return;
     }
     swap(l, randint(l, u));
     m = l;
     for (i = l+1; i <= u; i++){
          if (x[i] < x[l]){
               swap(++m, i);
          }
     }
     swap(l, m);
     quicksort(l, m-1);
     quicksort(m+1, u);
}

เปงไง Beautiful ไหม?..

3 comments On Beautiful Code

Leave a reply:

Your email address will not be published.