master
1#include "hash.h"
2#include <stdio.h>
3
4int main(int argc, char *argv[]) {
5 printf("=== COMP-272 - Assignment 02 - Question 04 ===\n");
6 Hash *hash = hash_init(13);
7 int items[] = {1, 5, 21, 26, 39, 14, 15, 16, 17, 18, 19, 20, 111, 145, 146};
8 int n = sizeof(items) / sizeof(int);
9
10 printf("Insert items into hash\n");
11 for (int i = 0; i < n; i++) {
12 int key = items[i];
13 long value = key * 10;
14 printf("(%d:%d) ", key, value);
15 hash_set(hash, key, (void *)value);
16 }
17
18 printf("\nInspect hash table\n");
19 hash_inspect(hash);
20
21 printf("Retrieve each item from the table\n");
22 for (int i = 0; i < n; i++) {
23 int key = items[i];
24 printf("(%d:%d) ", key, hash_get(hash, key));
25 }
26
27 printf("\nBye\n");
28 return 0;
29}