algoritmus

Papp Zoltán zombi at c2.hu
Fri Dec 1 00:10:44 CET 2006


2006.11.30. 20:53:45 dátumon vajk fekete <halaloszto at yahoo.co.uk> írta:

> void quick_sort (element_t *table, int length)
> {
>   element_t temp, *left=table, *right=table+length-1;
>   keytype reference_key = table[length/2].key;   /* for partitioning */
>
>   do {                                           /* partitioning */
>     while (left->key < reference_key)  left++;   /* search from left */
>     while (reference_key < right->key) right--;  /* search from right */
>     if (left <= right) {
>       temp = *left;  *left++ = *right;  *right-- = temp;   /* swap, then  
> ...*/
>     }                                        /* ... bypass swapped  
> elements */
>   } while (left <= right);
>   if (table<right)  quick_sort (table,right-table+1);
>   if (left<table+length-1)  quick_sort(left,table+length-left);
> }
>
>
> Hat ez tokeletes pelda arra hogyan lehet a C sajatossagait kihasznalni  
> olvashatatlan,
> karbantarthatatlan kod irasara.

Hát kérem nemhiába Pongor írta. Te nem vizsgázál nála? Amikor elénktolta a  
3 soros C programot (faltól falig minden sor), hogy mit ír ki, tele  
c=++a+b+++++c és hasonló hülyeségekkel.
Ráadásul papíron kellett (szintaktikailag is helyes!) tökéletes programot  
írni...

-- 
Papp Zoltán
OneWay Electronics



More information about the Elektro mailing list