Skip to content
Snippets Groups Projects
Commit d41b0862 authored by dario.genga's avatar dario.genga
Browse files

Add finished ex2

parent 96ad637c
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,24 @@ hm *hm_set(hm *hm, const char *const key, double value) {
return hm;
}
void hm_print(const hm *const hm) {
for (int i = 0; i < hm->length; i++) {
printf("%d: ", i);
entry *e = hm->entries[i];
while (e != NULL && e->key != NULL) {
printf("(");
printf("%s, ", e->key);
printf("%0.1f)", e->value);
if (e->next != NULL && e->next->key != NULL) {
printf(", ");
}
e = e->next;
}
printf("\n");
}
}
int main() {
int length = 10;
......@@ -104,13 +122,15 @@ int main() {
hm_set(hashmap, "bjkd", 1.9);
// print
hm_print(hashmap);
hm_set(hashmap, "ajkt", 0.1);
hm_set(hashmap, "ajku", 9.1);
hm_set(hashmap, "ajkx", 2.9);
// print
printf("-------------------\n");
hm_print(hashmap);
hm_destroy(&hashmap);
return EXIT_SUCCESS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment