int main(int argc, char const *argv[]) { void reg(float scores[40]); float best(float scores[40]); float worst(float scores[40]); void report(float scores[40]); float average(float scores[40]); float scores[40]; int position; printf("scores average\n"); reg(scores); printf("The best score is %f \n", best(scores)); printf("The worst score is %f \n", worst(scores)); printf("Score report \n"); report(scores); printf("The average is %f \n", average(scores)); printf("Give me a number of score \n"); scanf("%i", &position); if (position >= 0 && position <= 40) { printf("The score that you look is %f \n", scores[position]); } return 0; }
/** * Given a containing rectangle and a list of rectangles to be laid out inside it, attempts * to lay out the rectangles with their aspect ratios close to 1. * * @param rect The outer rectangle into which children will be laid out. * @param min_dim The size of the smallest dimension of the current layout rectangle. * @param is_height Non-zero if min_dim is the rectangle's height. * @param areas A list of areas to be laid out as rectangles. There must be at least 2 areas. * @param num_areas The number of areas to be laid out. * @param children A list of rectangles to store the resulting layout. * @param last_row_start Holds the pointer to the first rectangle in the last row to be laid out (i.e., that contains rectangles). * @param last_row_size Holds the number of rectangles in the last row to be laid out. * @param rect_has_children Boolean indicating whether the current parent rectangle contained children upon return. If so, it contains * the rectangles from last_row_start to last_row_start + last_row_size. * @param layout_size The size of the list of rectangles in the current layout. This should always start at 0. * @param prev_sum The sum of all the areas in the current layout. Should always start at 0. */ static void pb_squarify_internal(pb_rect *rect, float min_dim, int is_height, float* areas, size_t num_areas, pb_rect *children, size_t layout_size, float prev_sum, pb_rect** last_row_start, size_t* last_row_size, int* rect_has_children) { /* Current child to be laid out is the last one to have been added to the row */ pb_rect *child; float child_area; /* Added all children without messing up aspect ratio */ if (layout_size == num_areas) { layout(rect, prev_sum, min_dim, is_height, areas, children, layout_size); *last_row_start = children; *last_row_size = layout_size; *rect_has_children = 1; return; } /* Get a pointer to the child we're currently adding to the parent rectangle */ child = children + layout_size; child_area = areas[layout_size]; /* Determine whether adding the child to the current row would worsen the row's aspect ratios */ if (layout_size == 0 || worst(prev_sum, min_dim, areas, layout_size) >= worst(prev_sum + child_area, min_dim, areas, layout_size + 1)) { layout_size++; prev_sum += child_area; pb_squarify_internal(rect, min_dim, is_height, areas, num_areas, children, layout_size, prev_sum, last_row_start, last_row_size, rect_has_children); } else { layout(rect, prev_sum, min_dim, is_height, areas, children, layout_size); /* Move the layout rectangle to the appropriate spot */ if(is_height) { rect->w -= children[0].w; rect->bottom_left.x += children[0].w; } else { rect->h -= children[0].h; rect->bottom_left.y += children[0].h; } /* Only go until we have no more children to lay out */ num_areas -= layout_size; if (num_areas == 0) { *last_row_start = children; *last_row_size = layout_size; *rect_has_children = 0; return; } /* Continue to the next set of children */ children += layout_size; areas += layout_size; layout_size = 0; prev_sum = 0; is_height = rect->h < rect->w; pb_squarify_internal(rect, is_height ? rect->h : rect->w, is_height, areas, num_areas, children, layout_size, prev_sum, last_row_start, last_row_size, rect_has_children); } }