习题5.10 线性探测法的查找函数 (20 分)

Position Find( HashTable H, ElementType Key )
{
  int a=Key%H->TableSize;
  int cou=0;
  while(H->Cells[a].Info!=Empty&&cou!=H->TableSize)
  {
    cou++;
    if(H->Cells[a].Data==Key)
     return a;
    else
     a=(a+1)%H->TableSize;
  }
  if(H->Cells[a].Info==Empty)
  return a;
  else
  return ERROR;
}

猜你喜欢

转载自blog.csdn.net/yubai258/article/details/83243250