亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hsort.c

?? 有關分區的源程序,能夠把硬盤容易的分成許多分區
?? C
字號:
/***********************************************************************/
/*  HSORT(): Heap Sort function.                                       */
/*  See the function declaration for calling information.              */
/*  Set STANDALONE != 0 to compile a shell to test the sucker;         */
/*    to compile just hsort() and its supporting functions, set        */
/*    STANDALONE = 0.                                                  */
/* DEBUG determines how much debugging info is displayed; 0 is none.   */
/* TRACE determines what level of tracing information is displayed;    */
/*    0 is none.                                                       */
/* Function is by Bruce Feist; please contact me on CompuServe with    */
/*    a message on BORPRO or through EASYPLEX if you have any          */
/*    questions or problems.                                           */
/* Feel free to make use of this code in your own programs.            */
/***********************************************************************/

#define DEBUG 0
#define STANDALONE 0
#define TRACE 0

#include <stdio.h>
#include <process.h>
#include <alloc.h>
#include <stdlib.h>
#include <mem.h>

static void pascal swap (unsigned int, unsigned int);
static void pascal buildheap (void);
static void pascal heapify (unsigned int, unsigned int);
void       hsort (void *, unsigned int, unsigned int, int (*)());

#if STANDALONE
static int int_compare (int *, int *);
static void showarray (int *, unsigned int, unsigned int);

void
main()
{
  unsigned int n_entries, entry_num;
  int *entries;

  printf ("How many entries do you wish to sort?  ");
  scanf ("%d", &n_entries);
  entries = (int *) malloc (n_entries * sizeof(int));

  for (entry_num = 0; entry_num < n_entries; entry_num++)
  {
    printf ("Enter #%d:  ", entry_num);
    scanf ("%d", entries + entry_num);
    }

  printf ("\n");

  hsort (entries, n_entries, sizeof (int), int_compare);

  showarray (entries, 0, n_entries - 1);

  exit (0);
  }


int
int_compare (i, j)
int *i, *j;
{
  return (*i - *j);
  }


void
showarray(base, bot, top)
int *base;
unsigned int bot, top;
{
  unsigned int i;

  for (i=bot; i<=top; i++)
    printf("%4d", base[i]);
  printf ("\n");
  }

#endif   /* STANDALONE */


static int (*static_compare) (void *, void *), static_width, static_n_elements;
static void *temp_element, *static_base;

void
hsort(base, n_elements, element_width, compare)
/***************************************************************************/
/* Heap Sort routine -- similar in calling sequence to standard 'qsort()'  */
/* Base is a pointer to an array                                           */
/* n_elements is the number of elements in the array                       */
/* element_width is the width of each element in bytes                     */
/* compare is a function of two pointers (each to an element of the array) */
/*    returning a negative value if the first is smaller, a positive value */
/*    if the second is smaller, or 0 if they should be sorted the same.    */
/* Warning!  This function will halt your program if it can't allocate     */
/*    element_width bytes using malloc().                                  */
/***************************************************************************/

void *base;
unsigned int  n_elements, element_width;
int           (*compare)();
{
  register unsigned int i;

#if TRACE >= 1
  printf("hsort(base at %lX, %u elements, width %u, compare at %ld)\n",
         (long) base, n_elements, element_width, (long) compare);
#endif

  /* this lets us reference elements of array as 1 to n */

  (char *) base -= element_width;

  /*  The following assignments to static variables reduce the */
  /* overhead of subroutine calls later.                       */

  static_width = element_width;
  static_compare = compare;
  static_n_elements = n_elements;
  static_base = base;

  temp_element = malloc (element_width);

  if (temp_element == NULL)
  {
    fputs ("Unable to allocate room for a temporary element in hsort().\n",
           stderr);
    exit (1);
    }


  buildheap ();

  for (i = n_elements; i>1; i--)
  {
    swap (1, i);
    heapify (1, i-1);
    }

  free (temp_element);
  }


static void pascal
swap (i, j)
unsigned int i,j;

{
  register int temp_int;
  long temp_long;

#if TRACE >= 2
  printf("swap (i=%d, j=%d) called.\n",i,j);
#endif

  switch (static_width)
  {
    case sizeof (int): temp_int = ((int *) static_base) [i];
                       ((int *) static_base) [i] = ((int *) static_base) [j];
                       ((int *) static_base) [j] = temp_int;
                       break;

    case sizeof(long): temp_long = ((long *) static_base) [i];
                       ((long *) static_base) [i] = ((long *) static_base) [j];
                       ((long *) static_base) [j] = temp_long;
                       break;

    case sizeof(char): temp_int = ((char *) static_base) [i];
                       ((char *) static_base) [i] = ((char *) static_base) [j];
                       ((char *) static_base) [j] = (char) temp_int;
                       break;

    default:           memcpy (temp_element,
                               (char *) static_base + i*static_width,
                               static_width);
                      memcpy ((char *) static_base + i*static_width,
                              (char *) static_base + j*static_width,
                              static_width);
                      memcpy ((char *) static_base + j*static_width,
                              temp_element,
                              static_width);
                      break;
    }  /* end of switch */

#if TRACE >= 2
  printf ("swap exited.\n");
#endif
  }


static void pascal
buildheap()

{
  register unsigned int element_number;

#if TRACE >= 2
  printf("buildheap() called.\n");
#endif

  for (element_number = static_n_elements >> 1;
       element_number >= 1;
       element_number--)
  {
#if DEBUG >= 2
    printf ("buildheap calls heapify (%d, %d).\n",
            element_number, static_n_elements);
#endif
    heapify(element_number, static_n_elements);
    }

#if TRACE >= 2
  printf ("buildheap exited.\n");
#endif
  }


#define son1(i)    (i << 1)
#define son2(i)    ((i << 1) + 1)
#define pointer(i) ((char *) static_base + i * static_width)
#define child_count(i, j) \
     (j > son1(i) \
       ? 2 \
       : j < son1(i) \
          ? 0 \
          : 1)


static void pascal
heapify (i,j)

unsigned int i, j;
{
  /* The following are static to avoid recursive stack overhead */

  static unsigned int son1i, son2i;
  static void *pson1, *pson2, *pi;
  static unsigned int k;

#if TRACE >= 3
  printf("heapify(i=%d, j=%d) called.\n", i, j);
#endif

  son1i = son1 (i);
  son2i = son2 (i);
  pson1 = pointer (son1i);
  pson2 = pointer (son2i);
  pi    = pointer (i);

#if DEBUG >= 2
  printf ("child_count (%d) = %d.\n", i, child_count(i, j));
#endif

  switch (child_count (i, j))
  {
    case 0: break;

    case 2: {
              k = (*static_compare) (pson1, pson2) > 0 ? son1i : son2i;
              if ((*static_compare) (pi, pointer (k)) < 0)
              {
#if STANDALONE && DEBUG >= 1
                printf ("heapify changes\n");
                showarray (static_base, 1, static_n_elements);
#endif

                swap (i, k);
                heapify (k, j);

#if STANDALONE && DEBUG >= 1
                printf ("into\n");
                showarray (static_base, 1, static_n_elements);
#endif
                }
              break;
            }  /* end case */

    case 1: if ((*static_compare) (pi, pson1) < 0)
            {
#if STANDALONE && DEBUG >= 1
              printf ("heapify changes\n");
              showarray (static_base, 1, static_n_elements);
#endif

              swap (i, son1i);
              heapify (son1i, j);

#if STANDALONE && DEBUG >= 1
              printf ("into\n");
              showarray (static_base, 1, static_n_elements);
#endif
              }
            break;
    }  /* end of case */

#if TRACE >= 3
  printf ("heapify exited.\n");
#endif
  }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品日日夜夜| 亚洲国产精品久久久久秋霞影院 | 麻豆91免费看| 午夜私人影院久久久久| 一个色在线综合| 天天影视网天天综合色在线播放| 亚洲专区一二三| 亚洲va欧美va人人爽| 五月激情综合色| 免费成人av在线播放| 国产精品一区在线观看乱码| 国产成人免费视频精品含羞草妖精| 国产永久精品大片wwwapp| 国产91高潮流白浆在线麻豆| 91在线porny国产在线看| 欧美三级日韩三级国产三级| 欧美一二三区在线观看| 久久精品一级爱片| 亚洲免费观看高清完整版在线| 一区二区不卡在线视频 午夜欧美不卡在 | 日韩一区二区三区免费看| 欧美一区二区三区小说| 久久综合精品国产一区二区三区 | 7777精品伊人久久久大香线蕉超级流畅 | 久久综合成人精品亚洲另类欧美| 久久久久久免费毛片精品| 国产精品丝袜久久久久久app| 一区二区三区在线看| 免费欧美在线视频| 北岛玲一区二区三区四区| 制服丝袜一区二区三区| 国产欧美精品一区| 丝袜诱惑制服诱惑色一区在线观看 | 色欧美片视频在线观看 | 国产成人午夜精品5599| 色呦呦国产精品| 精品欧美一区二区三区精品久久| 亚洲国产精品成人综合| 亚洲一区二区三区在线播放| 国产福利电影一区二区三区| 欧美性一二三区| 最近日韩中文字幕| 国产在线播放一区三区四| 精品1区2区3区| 亚洲色欲色欲www在线观看| 六月丁香婷婷色狠狠久久| 色拍拍在线精品视频8848| 久久精品一级爱片| 久久99精品久久久久久| 欧美色视频一区| 亚洲欧美日韩国产成人精品影院| 久久99久久精品欧美| 91精品综合久久久久久| 一区二区三区精密机械公司| 国产精品一区在线观看你懂的| 91精品国产色综合久久久蜜香臀| 亚洲免费在线电影| 粉嫩av一区二区三区| 久久一二三国产| 日本亚洲电影天堂| 欧美日韩国产首页| 亚洲精品国产第一综合99久久 | 国产欧美日韩精品一区| 日本aⅴ亚洲精品中文乱码| 欧美婷婷六月丁香综合色| 亚洲少妇最新在线视频| 丁香亚洲综合激情啪啪综合| 2023国产精品| 狠狠色综合日日| 久久久久亚洲综合| 国产一二三精品| 国产日产欧美一区| 国内精品久久久久影院色| 日韩一区二区三区观看| 欧美aⅴ一区二区三区视频| 5月丁香婷婷综合| 六月丁香婷婷色狠狠久久| 欧美久久一二三四区| 日日夜夜精品视频免费| 欧美放荡的少妇| 久久99精品久久久久| 欧美不卡一区二区三区四区| 国产自产视频一区二区三区| 欧美mv日韩mv国产网站app| 狠狠色丁香九九婷婷综合五月| 欧美tickle裸体挠脚心vk| 国产一区不卡在线| 亚洲欧美怡红院| 欧美最新大片在线看| 日韩在线一区二区三区| 欧美成人高清电影在线| 成人精品国产一区二区4080| 1000部国产精品成人观看| 欧美伊人久久久久久久久影院| 亚洲h在线观看| 日韩写真欧美这视频| 国产在线日韩欧美| 国产欧美日韩亚州综合 | 婷婷久久综合九色综合绿巨人| 欧美伦理电影网| 狠狠色2019综合网| 中文字幕一区二区不卡| 欧美日韩视频第一区| 国产一区二区三区观看| 亚洲天堂av一区| 日韩美女主播在线视频一区二区三区| 国产一区二区三区电影在线观看 | 精品国产污网站| 波多野结衣视频一区| 日日噜噜夜夜狠狠视频欧美人| 久久久久九九视频| 91极品视觉盛宴| 丁香激情综合五月| 美女高潮久久久| 亚洲免费观看视频| 久久毛片高清国产| 欧美三级资源在线| 99久久99久久免费精品蜜臀| 亚洲大片在线观看| 一区免费观看视频| 欧美大白屁股肥臀xxxxxx| 91麻豆精东视频| 国产福利一区二区| 日日夜夜免费精品视频| 亚洲免费电影在线| 国产日产亚洲精品系列| 欧美一区二区日韩| 欧美日韩在线一区二区| 成人av动漫网站| 国产毛片精品一区| 喷白浆一区二区| 香蕉久久夜色精品国产使用方法 | 99视频热这里只有精品免费| 激情五月婷婷综合网| 亚洲国产aⅴ天堂久久| 国产精品国产三级国产aⅴ中文| 日韩视频免费观看高清完整版在线观看| 成人黄色小视频| 国产经典欧美精品| 狠狠色丁香久久婷婷综| 蜜桃av噜噜一区二区三区小说| 亚洲综合一二三区| 亚洲一区二区三区自拍| 亚洲三级理论片| 亚洲欧美在线视频观看| 国产精品久久久久四虎| 中文天堂在线一区| 欧美激情综合五月色丁香小说| 精品成人在线观看| 久久久精品综合| 久久免费精品国产久精品久久久久 | 亚洲国产欧美另类丝袜| 亚洲精品亚洲人成人网| 亚洲精品国产高清久久伦理二区 | 欧美精品高清视频| 欧美军同video69gay| 欧美精品日韩综合在线| 欧美丰满一区二区免费视频| 欧美精品亚洲一区二区在线播放| 色94色欧美sute亚洲线路二 | 成人黄色大片在线观看| 成人av免费网站| 欧美自拍偷拍一区| 欧美日韩高清一区二区三区| 欧美日韩国产高清一区二区三区 | 国产一区二区福利| 高清不卡一区二区在线| 成人一区二区在线观看| 91一区一区三区| 欧洲色大大久久| 欧美一级高清片在线观看| 久久精品水蜜桃av综合天堂| 国产欧美精品一区| 亚洲影院理伦片| 日韩高清在线电影| 大桥未久av一区二区三区中文| 91一区一区三区| 欧美电影免费观看高清完整版| 久久先锋资源网| 一区二区三区国产精品| 美女一区二区视频| 99精品欧美一区| 在线综合亚洲欧美在线视频| 久久久影视传媒| 一区二区不卡在线播放| 久久激五月天综合精品| caoporn国产精品| 日韩亚洲欧美中文三级| 中国av一区二区三区| 午夜精品爽啪视频| 大尺度一区二区| 7777精品伊人久久久大香线蕉完整版 | 成人综合激情网| 欧美视频在线一区| 欧美韩日一区二区三区| 亚洲成a人片在线不卡一二三区 | 91麻豆精品国产91久久久久久| 久久女同互慰一区二区三区| 一级中文字幕一区二区| 国产成人综合网站|