Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Febrizia

    #1

    Array

    Scusate qualcuno conosce il codice esatto della funzione
    x gli array dell'"insertion sort". Mi serve l'algoritmo completo scritto in
    C.
    Vi ringrazio molto x l'aiuto.


  • Jens.Toerring@physik.fu-berlin.de

    #2
    Re: Array

    Febrizia <fabry@libero.i t> wrote:[color=blue]
    > Scusate qualcuno conosce il codice esatto della funzione
    > x gli array dell'"insertion sort". Mi serve l'algoritmo completo scritto in
    > C.
    > Vi ringrazio molto x l'aiuto.[/color]

    Sorry, my Italian isn't good enough for an answer - and comp.lang.c
    is in english anyway. Please understand that this isn't the right
    place for asking for source code - if you have trouble writing it
    show how far you got and people here will try to help you, but you
    must have made at least some effort of your own. And you really
    don't have to ask for an inplementation of insertion sort in C
    since a google search for "insertion sort" will turn up several in
    the very first hits.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
    \______________ ____________ http://www.toerring.de

    Comment

    • pete

      #3
      Re: Array

      Febrizia wrote:[color=blue]
      >
      > Scusate qualcuno conosce il codice esatto della funzione
      > x gli array dell'"insertion sort".
      > Mi serve l'algoritmo completo scritto in C.
      > Vi ringrazio molto x l'aiuto.[/color]

      void qsort(void *base, size_t nmemb, size_t size,
      int (*compar)(const void *, const void *))
      {
      unsigned char *array, *high, *low;
      unsigned char swap, *p1, *p2, *end;

      if (nmemb-- > 1) {
      array = base;
      do {
      low = array;
      high = array += size;
      while (compar(low, high) > 0) {
      p1 = low;
      p2 = high;
      end = p2 + size;
      do {
      swap = *p1;
      *p1++ = *p2;
      *p2++ = swap;
      } while (p2 != end);
      if (low == base) {
      break;
      }
      high = low;
      low -= size;
      }
      } while (--nmemb != 0);
      }
      }

      --
      pete

      Comment

      Working...