Dividiendo una matriz por igual en c
Pregunta
Estoy escribiendo una C en Linux, cuida a un padre y n niños.El padre toma el SQRT (Artesize) y el resto se divide igual sobre los NIÑOS N.
¿Cómo podría dividir el resto de la matriz por igual sobre los niños n? \
thnx de antemano :)
Solución
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
Otros consejos
Realmente no nos dice lo suficiente como para dar una respuesta 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
¿Con qué bit estás atascado?
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow