25 lines
No EOL
703 B
C
25 lines
No EOL
703 B
C
// htab_statistics
|
|
// Řešení IJC-DU2, příklad b), 22.4.2024
|
|
// Autor: Roman Nečas, FIT
|
|
// Přeloženo: gcc 11.4.0
|
|
|
|
#include <stdio.h>
|
|
#include "htab.h"
|
|
#include "htab_struct.h"
|
|
|
|
void htab_statistics(const htab_t *t) {
|
|
size_t max_len = 0, sum_len = 0;
|
|
for (size_t i = 0; i < t->arr_size; i++) {
|
|
size_t len = 0;
|
|
struct htab_item *item = t->arr_ptr[i];
|
|
while (item != NULL) {
|
|
len++;
|
|
item = item->next;
|
|
}
|
|
if (len > max_len)
|
|
max_len = len;
|
|
sum_len += len;
|
|
}
|
|
double avg_len = (double)sum_len / t->arr_size;
|
|
fprintf(stderr, "Statistiky delky seznamu: min=0, max=%zu, avg=%.2f\n", max_len, avg_len);
|
|
} |