Here's a simple solution using integer arithmetic:
void check(char boxes[], int total_count, int check_count)
{
int i;
for (i = 0; i < total_count; i++)
boxes[i] = '-';
for (i = 0; i < check_count; i++)
boxes[i * total_count / check_count] = 'x';
}
total_count- the total number of boxes, and check_count- the number of checks.
Firstly, it disables all checkboxes. Then he checks the flags check_count, scaling the counter by the number of boxes.
: , , . , x--x--, --x--x. ,
boxes[i * total_count / check_count] = 'x';
:
boxes[total_count - (i * total_count / check_count) - 1] = 'x';
0 <= check_count <= total_count, boxes total_count , , :