testhash.c

来自「数据结构与算法分析(C语言描述)的源代码 里面的代码的质量非常高」· C语言 代码 · 共 51 行

C
51
字号
#define SepChain    /* Define the appropriate hash algorithm */#ifdef SepChain    #include "hashsep.h"#endif#ifdef QuadProb    #include "hashquad.h"#endif#include <stdio.h>#define NumItems 400main( ){    HashTable H;    Position P;    int i;    int j = 0;    int CurrentSize;    H = InitializeTable( CurrentSize = 13 );    for( i = 0; i < NumItems; i++, j += 71 )    {    #ifdef QuadProb        if( i > CurrentSize / 2 )        {            H = Rehash( H );            printf( "Rehashing...\n" );            CurrentSize *= 2;        }    #endif        Insert( j, H );    }    for( i = 0, j = 0; i < NumItems; i++, j += 71 )    #ifdef SepChain        if( ( P = Find( j, H ) ) == NULL || Retrieve( P ) != j )    #endif    #ifdef QuadProb        if( Retrieve( ( P = Find( j, H ) ), H ) != j )    #endif            printf( "Error at %d\n", j );    printf( "End of program.\n" );    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?