i am writing a C in Linux, forks a parent and N children. the Parent takes the sqrt(ArraySize) and the rest is divided equally upon the N children.
how could i divide the rest of the array equally upon the N children?\
Thnx开发者_Python百科 in advance :)
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
You're not really telling us enough to give a full answer
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
Which bit are you stuck on?
精彩评论