Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pretty_print_heap(FILE* out, const int* v, unsigned n)
- {
- int w = ints_width(v, n - 1);
- int count = 0;
- int nbline = 0;
- count++;
- for (unsigned j = 0; j < n; j = 2 * j + 1)
- {
- nbline++;
- }
- int plus = w + 1;
- int t = (plus) * pow(2, nbline - 1);
- int g = 0;
- for (unsigned i = 0; i < n; i = i)
- {
- int did = 0;
- int s = t / count - w;
- int to_floor = (s / 2);
- int nbspaces = floor(to_floor);
- for (int h = 0; h < nbspaces; h++)
- fprintf(out, " ");
- int test = g;
- for (int l = g; l < count + test && i < n; l++)
- {
- if (g != 0 && did == 1)
- {
- for (int k = 0; k < s; k++)
- fprintf(out, " ");
- }
- for (int u = int_width(v[l]); u < w; u++)
- fprintf(out, " ");
- i++;
- g++;
- did = 1;
- fprintf(out,"%d" ,v[l]);
- }
- fprintf(out, "\n");
- count = count * 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement