Dividendo un array allo stesso modo in c
Domanda
Sto scrivendo un c in linux, forchette un genitore e n bambini.Il genitore prende la SQRT (arrivato) e il resto è diviso allo stesso modo sui n figli.
Come potrei dividere il resto dell'array ugualmente sui n figli? \
thnx in anticipo :)
Soluzione
int arraySize = 100; // You would get a count from the array here
int nChildren = 5; // This would be provided by you as a parameter to this function
int parentSize = sqrt(arraySize);
int remainder = arraySize - parentSize;
int nChildSize = (remainder / nChildren) + 1
. Altri suggerimenti
Non ci stai dicendo abbastanza per dare una risposta completa
Decide size of share for each child, also determine what to do with any "remainder"
For each child
allocate an array sufficient to hold the required number of value
populate the array
.
A quale bit sei bloccato?
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow