📄 main.cpp
字号:
#include "../../C/UTILITY.H"
#include "../../C/UTILITY.CPP"
#include "../../B/RANDOM.H"
#include "../../B/RANDOM.CPP"
#include "../../6/LINKLIST/LIST.H"
#include "../../6/LINKLIST/LIST.CPP"
#include <string.h>
#include "../../6/STRINGS/STRING.H"
#include "../../6/STRINGS/STRING.CPP"
#include "../RADIX/KEY.H"
#include "../RADIX/KEY.CPP"
#include "RECORD.H"
#include "RECORD.CPP"
void write_entry(Record c)
{
for (int i = 0; i < 8; i++)
cout << c.key_letter(i);
cout << "\n";
}
#include "HASH.H"
#include "HASHFN.CPP"
#include "HASH.CPP"
main()
{
int list_size = 1200;
Random dice;
char word[9];
word[8] = '\0';
cout << "If the word UNEXPECTED does not appear in the output,"
<< "the hash table \nappears to be working correctly." << endl;
int i;
List<Record> the_list;
Hash_table the_hash;
for (i = 0; i < list_size; i++) {
for (int j = 0; j < 8; j++)
word[j] = dice.random_integer(0, 26) + 'a';
Record target;
target.initialize(word);
if (the_list.insert(i, target) != success)
cout << " UNEXPECTED Overflow in filling list." << endl;
if (the_hash.insert(target) != success) {
if (i < hash_size) cout << "UNEXPECTED ";
cout << " Overflow in filling table." << endl;
}
}
for (i = 0; i < 1200; i += 100) {
Record x, y;
the_list.retrieve(i, x);
cout << i << " : ";
write_entry(x);
Key k = x;
if (the_hash.retrieve(k, y) != success) {
if (i < hash_size) cout << "UNEXPECTED ";
cout << " Record not found." << endl;
}
else write_entry(y);
}
the_hash.clear();
for (i = 0; i < 1200; i += 200) {
Record x;
the_list.retrieve(i, x);
if (the_hash.insert(x) != success)
cout << " UNEXPECTED Overflow in refilling table." << endl;
}
for (i = 0; i < 1200; i += 100) {
Record x, y;
the_list.retrieve(i, x);
cout << i << " : ";
write_entry(x);
Key k = x;
if (the_hash.retrieve(k, y) != success) {
if ((i/100) % 2 == 0) cout << "UNEXPECTED ";
cout << " Record not found." << endl;
}
else write_entry(y);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -