The task is as follows:
There are icons representing a specific process on the screen (5 icons):

[.... {1} {2} {3} {4} {5}] are all icons when all processes are active.
[.... {1} {.} {3} {.} {5}] is when processes 2 and 4 are not active

So there are no problems, but on the screen it looks illegitimate.

How to do this:

[.... {.} {.} {1} {3} {5}]

and when the activation process 2

[.... {.} {2} {1} {3} {5}]

so he just took an empty not occupied place.

Arduino project.

  • If a process is added then insert it into the first empty space. If a process is deleted, shift all processes after it by 1 element, put the last element empty or put the last process from the list in its place. - Unick
  • so in my question it is described that everyone should move and close the vacated places, but how to do it in the code, I understand that it is necessary to dig in the direction of the arrays, but this is where my understanding ends - Timur Mirkhaydarov
  • I roughly represent the 5 functions (icons bool fn_1 (int x1, bool status) .... bool fn_5 (int x5, bool status) take coordinates on x and return status) above them a function that checks the status of all functions and those that have returned 1, puts in a certain order and if in a number of functions the status has changed, she shifted the rest! - Timur Mirhaydarov
  • show your current code to begin with - Unick
  • so in the code there is not even a mention of this function, since it is not yet worked out and only in thought - Timur Mirhaydarov

1 answer 1

Like that:

void showInactive() { for (int n = 0; n < 5: ++n) if (procInactive(n)) showInactiveProc(n); } void showActive() { for (int n = 0; n < 5: ++n) if (procActive(n)) showActiveProc(n); } void showProcesses() { showInactive(); showActive(); } 
  • Thank! as I understand it, we survey and divide into two types of active and non-active! and now how can inactive hide from the screen, leaving only the active ones and grouping them together (without spaces)? - Timur Mirhaydarov
  • Just don't show them, that's all. - Vanyamba Electronics
  • @ TimurMirhaydarov You would mark the person's comment as 'the solution of the question' - the best "thank you" =) - Valentyn Hruzytskyi