0

私はLinuxでCを書いていて、親とN人の子をフォークしています。親はsqrt(ArraySize)を取り、残りはN個の子に均等に分割されます。

配列の残りの部分をN個の子に均等に分割するにはどうすればよいですか?\

事前にThnx:)

4

2 に答える 2

3
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
于 2011-05-20T08:18:52.977 に答える
1

あなたは完全な答えを与えるのに十分なことを私たちに本当に言っていません

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

あなたはどのビットに固執していますか?

于 2011-05-20T08:14:48.447 に答える