hashtable.cpp
来自「包含各种测试,查找和算法等代码,如冒泡算法,树的遍历,链表,队列,堆栈等」· C++ 代码 · 共 34 行
CPP
34 行
#include <iostream.h>
typedef int KeyType;
#include "DataType.h"
#include "HashTable.h"
void main(void)
{
HashTable myHashTable(13);
DataType a[] = {180,750,600,430,541,900,460}, item;
int i, j, n = 7;
for(i = 0; i < n; i++)
myHashTable.Insert(a[i]);
for(i = 0; i < n; i++)
{
j = myHashTable.Find(a[i]);
if(j > 0)
{
item = myHashTable.GetValue(j);
cout << "j = " << j << " ht[] = " << item.key << endl;
}
}
int k = myHashTable.IsIn(430);
if(k == 1) cout << "数据元素430在哈希表中";
else cout << "数据元素430不在哈希表中";
myHashTable.Delete(430);
k = myHashTable.IsIn(430);
if(k == 1) cout << "\n数据元素430在哈希表中";
else cout << "\n数据元素430不在哈希表中";
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?