12.17`

#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 11
#define KEY 11

void Hash_Insert(int Hash[],int x)
{
int i=0,t,c=0,ave;
t=x%KEY;
while(i<MAXSIZE)
{

    if(Hash[t]<=-1)
    {
        Hash[t]=x;
        i++;
        break;
    }
    else
        t=(t+1)%KEY;
    c++;

}
if(i==MAXSIZE)
    printf("Hash is full\n");
ave = c*1.0/i;
printf("ave is%d",ave);

}

void Hash_Search(int Hash[],int x)
{
int i=0,t;
t=x%KEY;
while(Hash[t]!=-1&&i<MAXSIZE)
{
if(Hash[t]x)
{
printf(“Hash position of %d is %d\n”,x,t);
break;
}
else
t=(t+1)%KEY;
i++;
}
if(Hash[t]
-1||i=MAXSIZE)
printf(“no found\n”);
}

void Hash_Delelt(int Hash[],int x)
{
int i=0,t;
t=x%KEY;
while(Hash[t]!=-1&&i<MAXSIZE)
{
if(Hash[t]x)
{
Hash[t]=-2;
printf("%d in Hash list is deleted \n",x);
break;
}
else
t=(t+1)%KEY;
i++;
}
if(i
MAXSIZE)
printf(“delete fail\n”);

}

int main()
{

return 0;

}

猜你喜欢

转载自blog.csdn.net/cruel2436/article/details/85043535
今日推荐